Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Results with 2 different criteria Post Reply Post New Topic
Author Message
Csukardi151
Newbie
Newbie


Joined: 02 Feb 2009
Location: United States
Online Status: Offline
Posts: 8
Quote Csukardi151 Replybullet Topic: Results with 2 different criteria
     Posted: 31 Jan 2012 at 2:54pm
Hello,

I'm trying to get a report to give me our sales orders based on the category of the order and also based on the parts inside the order.

Orders are places into categories based on what products they are associated with. Categories A, B and C. Parts are also placed into categories based on what products they belong in. Also Categories A, B and C.

I want the report to give me results on all orders in the C category and all orders that contain C parts (but are not in the C category for the order) I have a formula in the report record field saying something like this:

{Table.OrderLabel} = "C" or
{Table.PartLabel} = "C".

This is correctly giving me all orders in the C category.  It is not correctly giving me the results for orders not in the C category but have C labeled parts.

It WILL list the orders that contain C parts, but it will completely void out any other parts associated with that order. It will only show the C parts, giving me wrong net dollars since there should be more parts listed within that order.

I hope my explanation makes sense. I'm sure there is a way to do this, i just can't figure it out :(

Thank you,
Steve
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 01 Feb 2012 at 1:42am
It's because you're only asking it to return records not orders with part label c, I assume what you meant is if an order not in order label c contains a part of partlabel c you want to return the entire order?
 
First of all create a group on orderlabel.
 
Now create a formula as follows;
Cpartformula
if table.partlabel = "C" then 1 else 0
 
now amend your formula above to the following;
 
if table.orderlabel = "C" or
 
If I've understood your explanation correctly that should get you what you need.
 
Regards,
Ryan.
IP IP Logged
Csukardi151
Newbie
Newbie


Joined: 02 Feb 2009
Location: United States
Online Status: Offline
Posts: 8
Quote Csukardi151 Replybullet Posted: 01 Feb 2012 at 2:48am
Thank you Ryan. You did understand my explanation perfectly.
 
I will give this a try shortly and let you know how I do!
IP IP Logged
Csukardi151
Newbie
Newbie


Joined: 02 Feb 2009
Location: United States
Online Status: Offline
Posts: 8
Quote Csukardi151 Replybullet Posted: 01 Feb 2012 at 5:42am
Ok after playing around a bit. I was able to achieve what I was looking for, thank you! However, I seemed to have created another problem in the process. Unfortunately I don't know much about Crystal and its options, i'm just the person who has the most knowledge of it in the company.
 
I've always just used record selection and never really understood record selection vs group selection. After reading your suggestion, I realized that group selection allowed me to put in formula's that work with sum's and groups (where record selection only does records). I still do not understand much of record vs group.
 
My current problem now.
 
My Record selection has a formula saying:
{table.date} in {?Startdate} to {?Enddate}
 
My group selection has the forumula you suggested above.
 
To give you further explanation of how my report looks, I have 2 groups. Order numbers are in a group (Group 2), then group 1 just groups everything by regions. So when running the report, it shows regions, drill down to the order numbers.
 
I have the {table.netdollars} in the details, then sum of {table.netdollars} in group 2 and lastly, another sum of {table.netdollars} in groupr 1 (the regions group).
 
Group 2 sums up the net dollars perfectly from the details. Before I had made the changes using the record and group selection, the region group (group 1) also summed up group 2 correctly. After I made the changes, group 2's sum is off, it seems to be pulling more data than what is currently showing on the report. Any ideas?
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 01 Feb 2012 at 5:52am
I'm not fully understanding the problem;
Group 2 sums up the net dollars perfectly from the details.
then
After I made the changes, group 2's sum is off
:p
 
I'm guessing what you're saying is the region subtotal isn't correct? I always make my subtotals manually using the formula editor rather than using the expert.
 
Depending on which subtotal is wrong (I'm going to assume region for example's sake) make a formula as follows and replace the expert generated subtotal with it.
 
sum({table.netdollars},{table.region})
 
The report would look like this eventually;
 
DETAILS: {table.netdollars}
GROUP 2 H/F: Sum({table.netdollars},{table.orderlabel})
GROUP 1 H/F: Sum({table.netdollars},{table.region})
REPORT H/F: Sum({table.netdollars})
 
Hopefully that helps, otherwise let me know anything else that may help me to help you.
 
Regards,
Ryan.


Edited by rkrowland - 01 Feb 2012 at 5:56am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Feb 2012 at 6:10am
You will have to use running totals or shared variable formulas for your grand totals (or totals that had group selection criteria exclusions).
Sum({table.netdollars}) is calculated before the group selection criteria is applied (this is why the group selection criteria can work).
RTs and variable formulas are created after the group selection is applied.


Edited by DBlank - 01 Feb 2012 at 6:14am
IP IP Logged
Csukardi151
Newbie
Newbie


Joined: 02 Feb 2009
Location: United States
Online Status: Offline
Posts: 8
Quote Csukardi151 Replybullet Posted: 01 Feb 2012 at 6:29am
Thanks again guys. And yes Ryan, I had meant Group 1 was being miscalculated.
 
I will give this a shot. Thanks again!
IP IP Logged
joebuzz83
Newbie
Newbie


Joined: 02 Feb 2012
Online Status: Offline
Posts: 2
Quote joebuzz83 Replybullet Posted: 02 Feb 2012 at 6:08am
I have a similar issue. I have a formula that looks like this:

{trans_detail.paid_amt}<>0 and not isnull({trans_detail.paid_amt}) or {trans_detail.adj_amt}<>0
then 0

I want to see a 0 if one of the two fields meets the condition. Unfortunately, the formula is only showing the latter and then showing the rest of the cells as blank.

How can I make this work properly?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Feb 2012 at 6:17am
I think you need some more parenth and always use the isnull condition first
 
(not (isnull({trans_detail.paid_amt})) and {trans_detail.paid_amt}<>0)
or
{trans_detail.adj_amt}<>0
then 0
 
 
or you can change the value in the formula editor to 'use defualt values for NULLS' so you do not have to worry about the NULL value killing your evalution and then you can just use
 
{trans_detail.paid_amt}<>0 or {trans_detail.adj_amt}<>0 then 0
 
However both of these have no ELSE condition so they will always return a 0 as that would be the default ELSE value. You will have a hard time seeing if it is doing anything


Edited by DBlank - 02 Feb 2012 at 6:18am
IP IP Logged
joebuzz83
Newbie
Newbie


Joined: 02 Feb 2012
Online Status: Offline
Posts: 2
Quote joebuzz83 Replybullet Posted: 02 Feb 2012 at 6:29am
Wow. you are great! Problem resolved! I went to report properties and selected null to default option.
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