Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Include Nulls Post Reply Post New Topic
Author Message
jennykehr
Newbie
Newbie
Avatar

Joined: 08 Sep 2009
Location: United States
Online Status: Offline
Posts: 3
Quote jennykehr Replybullet Topic: Include Nulls
     Posted: 08 Sep 2009 at 2:00pm
I am trying to filter my data by two different fields.  The first is the account and the second is the department.  When I try to filter by departments it does not include anything that does not have a department.  I tried left outer join on the department but it won't let me...."Failed to retrieve data from the database.  Database Connection Error: If tables are already linked then the join type cannot change."  I also tried to select records by account and then group select  by department.  As soon as I put the department anywhere it drops out my records that don't have a department.  I need to select within a range plus nulls or exclude a range.  Help?
Jenny Kehr
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Sep 2009 at 2:39pm
What is your data source type?
Do you have the ability/rights to create a view or stored procedure to use instead of the tables?
IP IP Logged
jennykehr
Newbie
Newbie
Avatar

Joined: 08 Sep 2009
Location: United States
Online Status: Offline
Posts: 3
Quote jennykehr Replybullet Posted: 08 Sep 2009 at 3:24pm
My data comes from a data warehouse.  I may be able to get access but I'm not familiar with stored procedures.  I'm trying to write an income statement and it is a bit cumbersome.  I'm not sure if I'm going about it the right way....using many subreports.
Jenny Kehr
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Sep 2009 at 5:27pm

If you can avoid sub reports IMO I recommend that you do. Sometimes you can't so don't agonize over it. Outer joins can become inner joins based on select criteria.

Joins are not automatically enforced in crystal. THey become enforced once you use a field from both tables involved in the join or if you use the enforcing options in the link set up.
Sometimes simply adding in an OR NULL(field) can correct the problem (along with the outer join)....
e.g. {table.Date} in {?startdate} to {?enddate} and ({table.department}={?department param} or isnull(table.department})
 
Often though you have to write a query outside of crystal using somehting like a view or stored procedure which becomes your source or in crystal using COMMAND to select all the data from one table and then join that to the other table.
Does this help?


Edited by DBlank - 09 Sep 2009 at 2:54pm
IP IP Logged
Luis2101
Newbie
Newbie


Joined: 14 May 2008
Online Status: Offline
Posts: 18
Quote Luis2101 Replybullet Posted: 09 Sep 2009 at 1:10pm
Hey that error you're getting happens when you have several fields (probably from different tables) that you're joining on and you're doing an outer join with one table and an inner join with another.

The other thing you can do is get a little fancy with your select expert formula, so for example you can have different conditions setup when the department is null than when it isn't. So if I understood correctly, something like:

if not isNull({Table.Dept}) then
(
   {Table.DateField} >= {?StartDate} and
   {Table.DateField} <= ?EndDate}
)
else
(
   true
)
IP IP Logged
jennykehr
Newbie
Newbie
Avatar

Joined: 08 Sep 2009
Location: United States
Online Status: Offline
Posts: 3
Quote jennykehr Replybullet Posted: 10 Sep 2009 at 1:24pm
Jenny Kehr
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum