Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unique counts - subtotals
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00455221
Message ID:
00456172
Views:
24
Hi Diana,

Not sure, why you're still having problems :( In my reply to you I gave you two SQLs: 1 produced total summary, then second selects everything from your table + several new fields from Total. Did you try it? Did you get the data, you want?

Otherwise, let's start again from the beginning. Please, describe your problem with as much info and details, you could think of. In this case we can give you more accurate advice.

Hopefully, we'll get it done.

BTW, I think, Daniel also gave you a good advice. Did it work?
>Thanks, Nadya for this technique. I learned a lot by setting it up and using it. However, I'm still only getting total visits from this technique, not unique clients. I think it's got to look something like:
>
>select nprimary, sum( I think I need a select DISTINCT statement here, but I don't know how to do that)....
>
>
>Diana
>
>>>The data looks something like this:
>>>
>>>ID  Visit Date   Primary Insurance  Age
>>>___ __________   _________________  ___
>>>1	12/19/00	BC			12
>>>1	12/20/00	BC			12
>>>1	12/21/00	BC			12
>>>2	12/18/00	MC			3		
>>>2	12/19/00	MC			3
>>>3	12/17/00	007			24
>>>4	12/17/00	BC			15
>>>4	12/18/00	BC			15
>>>4	12/19/00	BC			15
>>>5	12/18/00	BC			36
>>>5	12/19/00	BC			36
>>>
>>>The Report looks like this:
>>>
>>>Insurance report - clients by sponsor
>>>
>>>BC
>>>	Children:
>>>		1	12/19/00
>>>		1	12/20/00
>>>		1	12/21/00
>>>		4	12/17/00
>>>		4	12/18/00
>>>		4	12/19/00
>>>	Total Children (visits): 6
>>>
>>>	Adults:
>>>		5	12/18/00
>>>		5	12/19/00
>>>	Total Adults (visits): 2
>>>
>>>Total BC Visits: 8
>>>
>>>etc...
>>>
>>>What I want to do is include in the subtotals the unduplicated counts. The ID refers to a client, so the subtotals above would be 2 children under BC and 1 adult under BC. I understand how to do an unduplicated count outside of the report using the count(distinct id) concept on the cursor I'm using for the report and just adding that variable to my report, but I would only then get a count of the individual clients at the bottom of my report. I'm wondering how to get the subtotals to show unduplicated counts. Using an array of variables that I calculate outside of the report seems to be the way to go, but I don't know how to let the report writer know which group is which variable (IE BC, 007, etc.)
>>>
>>>Diana
>>
>>
>>Hi Diana,
>>
>>As I said, prepare data before hyand, e.g.:
>>
>>select Primary, sum(iif(age<18,1,0)) as ChildVisits, ;
>>       sum(iif(age>=18,1,0)) as AdultVisits;
>>       from Visits ;
>>       group by Primary, ;
>>       into cursor curTotal
>>
>>select * from Visits inner join curTotal on Visits.Primary=curTotal.Primary ;
>>        into cursor curFinal && Here I'm not 100% sure, you may use Lookup function instead
>>
>>
>>Now you have all data, and designing report would be very easy.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform