cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Creating count from queried fields

Former Member
0 Likes
1,043

Post Author: John

CA Forum: Formula

Hello all. Newbie here to the forum and CR.

Running CR 9

I have a report that extracts certain data from the database. A field that displays "test code", is not part of the original search criteria. I have been asked to total "test code" but, I don't know how to count the records from the extracted data.

For example, I'm pulling in everyone with a last name that begins with a "J" and who came in the store from 01/01/07 - 01/31/07. I then list the data and also print their address, city, state, zip, and "test code". The "test code" is one of 3 possible codes. I want to have 1 running total for each of these 3.

My knowledge allows me to create a running total on the field but, the total is from ALL of the records that match.

So, if we had 45 people with "J" and 01/01/07 - 01/31/07, the running total will be 67 because it is finding all data sets that match it's code. It isn't pulling from the original search criteria of "J" and 01/01/07 - 01/31/07.

Any help is appreciated.

John

View Entire Topic
Former Member
0 Likes

Post Author: yangster

CA Forum: Formula

A running total runs along side the data so it should never be placed in a header or the detail section.It must always reside in a group footer, page footer or report footer.Your basic running total in crystal will initilize at the report header, evaluate at the detail level and display the value in the report footer.So for your generalized case you have a simple running total that starts a count at 0 to start the report.You running total should be setup like thisField to summarize -> Product_IDType of summary -> countEvaluate - using formula -> inside formula typed in (if product_id = 4344211 then true else false)Reset -> neverAnd it won't matter if you put it in the GF2, GF1, PF, or RF the value will always be 4. If your report spans multiple pages though you should not put the formula in the PF as it report the running total as of the page but keep on totaling to the next page.My suggestion to you would be to test your report with a manual running total to see exactly where your numbers counting is going astray.To do that create 3 formulas@init_count (place in report header)whileprintingrecords;numbervar a;a:= 0@eval_count (place at the detail level)whileprintingrecords;numbervar a;if product = 4344211 thena := a + 1@display_count (place in the report footer)whileprintingrecords;numbervar a;athis will show you exactly what is being counted for every single item in your reportnormally you'd use a manual running total to get a summary of a summary or to sum a value at a group level but this should help you decode what is causing you buggy datahope this helps