Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Flag if criteria not met Post Reply Post New Topic
Author Message
AESone
Newbie
Newbie


Joined: 14 May 2009
Location: Australia
Online Status: Offline
Posts: 4
Quote AESone Replybullet Topic: Flag if criteria not met
    Posted: 17 May 2009 at 5:15pm

I have client records and attached to them I have 0 to many achievement records.

I want to flag any client records where there is no achievement record attached that meets my criteria or no achievement record at all.

Criteria
"      category ID = 1
"      date  > 01/05/09 and < 31/05/09


I thought I would simply group my report by client and put an if statement field in the group header. The If statement would then give me a True if it found an achievement record that met the criteria and False if NO record was found that met the criteria. False being the flag. I have since discovered that a formula will only consider the first record if it is placed in the group header(and the last record if in the footer). If I place my "if statement" field in the details section it does work but it then creates a line for every achievement record belonging to that client. This is not what I'm after.

What I really want is a list of clients with a simple true or false to flag if that client has a record that meets the criteria or not.

 

 
 


Edited by AESone - 17 May 2009 at 10:08pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 May 2009 at 6:48am
You can "flag" each record with a 1 or 0 then sum on that to flag the client.  You also mention you need to include records with no achievements. If you are joining tables make sure you use a left join to address that (unless you wanted them excluded to start with).
Group on your client record and place this formula in the details.
if  {table.category ID} = 1 and  {table.date}  in #05/01/2009# to < #05/31/2009# then 1 else 0
Create a SUM on formula.
Place it in the client header.
you can either suppress all the clients with a SUM>0 or exclude them in the select expert group selection critieria (or the inverse if you want only clinets that had a record in that time period).


Edited by DBlank - 18 May 2009 at 6:50am
IP IP Logged
AESone
Newbie
Newbie


Joined: 14 May 2009
Location: Australia
Online Status: Offline
Posts: 4
Quote AESone Replybullet Posted: 18 May 2009 at 5:17pm
Thanks DBlank, it's seems so simple once you have the answer.
 
That is working great but Client records with no Achievement records are still being filtered out. I am using left outer join. Is that all I should need to do?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 May 2009 at 6:57pm
Where there are no records it will most likely be null instead of 0.
Add in isnull(field) or sum = 0

Edited by DBlank - 18 May 2009 at 6:59pm
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.