Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Creating a Formula Output based on Subtables Post Reply Post New Topic
Author Message
Stanno
Newbie
Newbie
Avatar

Joined: 19 Jan 2011
Location: United Kingdom
Online Status: Offline
Posts: 9
Quote Stanno Replybullet Topic: Creating a Formula Output based on Subtables
     Posted: 19 Jan 2011 at 7:09am
Hi there people.
 
Got a query for your mighty brains, if you can help me out with this, that would be quite several awesomes.
 
I need to be able to build a report for management that basically counts the number of events that are attended, and also split by event type as well. 
We have two tables, Events, and Eventtypes.
 
Events can be as little as the following for this example:
 
ID, ClientSerial, Date, Attended
 
Each event is linked to a set of Eventtypes, being the actual components recorded by workers for the event they're recording.  Looks kinda like this:
 
EventTypeID, EventID, Eventtype
 
That making sense?  This would probably best be described by example.
 
Events Table
EventID¨¨ClientSerial¨¨Date¨¨¨¨¨¨Attended
1000¨¨¨¨6000¨¨¨¨¨¨¨01/12/2010¨¨True
1001¨¨¨¨6005¨¨¨¨¨¨¨07/12/2010¨¨False
1003¨¨¨¨7291¨¨¨¨¨¨¨08/12/2010¨¨True
 
Eventtype Table
ID¨¨¨¨EventID¨¨Eventtype
10000¨¨1000¨¨¨¨triage
10001¨¨1000¨¨¨¨session6
10002¨¨1001¨¨¨¨session2
10003¨¨1001¨¨¨¨session4
10004¨¨1001¨¨¨¨session7
10005¨¨1003¨¨¨¨session3end
10006¨¨1003¨¨¨¨discharge
 
What I would like to do, is create a formula with a name EventHasTriage, that would do the following:
For each Event.EventID, looking at the related Eventtype.EventID, that if any Eventtype.Eventtype = 'Triage' then EventHasTriage = 'Triage', else EventHasTriage = 'Other'
 
Big%20smile
 
Is there help to be had? 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jan 2011 at 7:16am
group on eventid
create a formula field called @has_triage as
if Eventtype.Eventtype = 'Triage' then 1 else 0
Sum this formula field at the group level of eventid
now create a formula called EventHasTriage
if
SUM(1">{@has_triage},{table.eventid})>0 then  'Triage' else 'Other'


Edited by DBlank - 19 Jan 2011 at 7:17am
IP IP Logged
Stanno
Newbie
Newbie
Avatar

Joined: 19 Jan 2011
Location: United Kingdom
Online Status: Offline
Posts: 9
Quote Stanno Replybullet Posted: 19 Jan 2011 at 7:33am

Thank you for your damn quick reply.

 
I'm half way through what you've suggested, and am already getting a 0 or 1 that's correct, so I can work from there if I need to.
 
Before I even entered your final equation into the formula workshop, I was wondering about the " you have in that line.  Sure enough, when I tried to check it, gave an error.  I went with the following line:
 
if SUM(0">{@has_triage},{Events.EventID})>0 then 'Triage' else 'Other'
 
It worked fine then.
 
So, thank you muchly!  I didn't expect to get this one done this evening.  Sacrifice of the small furry animal of your choice now available upon reply.
 
Cheers.
IP IP Logged
Stanno
Newbie
Newbie
Avatar

Joined: 19 Jan 2011
Location: United Kingdom
Online Status: Offline
Posts: 9
Quote Stanno Replybullet Posted: 19 Jan 2011 at 7:34am
ahh, it added a mystery 0" before mine... must be an interpretation issue *slaps server*
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jan 2011 at 8:05am
Sorry about the mystery item. The AT sign often does a little quirky insert...
it should just be
if SUM({has_triage},{Events.EventID})>0 then 'Triage' else 'Other'
 
Maybe a jackalope?
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