Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selecting out a value when multiples exist

Status
Not open for further replies.

ssiroky

Technical User
Sep 4, 2003
17
US
I have a field {accident.causes} that I'm having some trouble with. I'm doing a count of accident causes for intersections. I have the intersections grouped and a count of accidents associated in the group footer. Now I need to do a count by {accident.causes} under each intersection. There can be multiple causes and there is no ordering of this field. For example there can be "run red light" and "inattentive". Here's my problem. If there is multiple causes, I want a count for each, which I know how to do, however, if the case has inattentive along with another cause, I want to only count the other cause. If it's inattentive alone, I want to count that as well. Is there a way to eliminate inattentive when it's shown with another cause? Thanks in advance for any help.
 
A simple means might be to group by this field and in the group header execute a subreport which counts the "inattentive" and returns a shared variable which you can use to suppress counts of causes based on whether there's any "inattentive".

If you need more help, let me know.

-k
 
Unfortunately, I'm not familiar with shared variables. I know how to do a sub report, but from there, I'm not sure what to do. Any ideas?
 
I'm not real versed in this, but here's a thought:
Use a formula to count the instances of each 'given' value of the CAUSES field using a LEFT(Right) statement to extract the data after the 'inattentive' portion of the string.

Still, how many different CAUSES values are possible?....& you'd need a COUNT formula customized for each.

Hope this helps.
 
OK, in the group header of Intersections in the main report use the following formula:

whileprintingrecords;
shared numbervar InattentiveCount:=0;

Right click the group header and select insert section below

Create a subreport which has the record selection set to only inattentives in this new section and assign the count to the shared varible, as in:

whileprintingrecords;
shared numbervar InattentiveCount:= count({table.field});

(make sure that you're link via the Intersections field)

Now in the group footer or details (anywhere after the subreport has fired), you can use the following formula to determine the number of inattentives:

whileprintingrecords;
shared numbervar InattentiveCount;

Now you can suppress sections or create custom Running Totals based on the count of Inattentives for each Intersection.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top