Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: summarizing For loop Post Reply Post New Topic
Author Message
Anna
Newbie
Newbie


Joined: 24 Jul 2011
Online Status: Offline
Posts: 10
Quote Anna Replybullet Topic: summarizing For loop
    Posted: 02 Aug 2011 at 5:20am
Please Anyone,
 
Help me to find out whats wrong with this formula. Why does it generate 0? There are fields to count but the formula returns 0.
 
NumberVar AntalPADL1:=0;
NumberVar Counter:=1;
 
For Counter:=1 to count({SOC_PERSON.PERSNR}) step 1 do (
If ({SOC_PERSON.PERSNR} <> next({SOC_PERSON.PERSNR})) then
  If({AOH_SNACINDEX2PADLGRUPP_SYS.PADLGRUPP}='1') then
        (AntalPADL1 = AntalPADL1 + 1;)
else
        (AntalPADL1 = AntalPADL1;)
);
 
NumberVar AntalPADL1
 
Many thanks in advance,
Anna
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 02 Aug 2011 at 7:22am
Take the "NumberVar" off of the last line.  You're redeclaring the variable which resets it to 0.
 
-Dell
IP IP Logged
Anna
Newbie
Newbie


Joined: 24 Jul 2011
Online Status: Offline
Posts: 10
Quote Anna Replybullet Posted: 03 Aug 2011 at 2:45am
Hi,
Thanks for the tip. I tried that but it still didnt do the trick. I am guessing that it might have something to do with processing or evaluation time.
 
What I have been trying to do but can't really seem to manage is this:
 
I have 5 groups for different hierarchies;
Region/Hospital/Doctor/Patient/Exec.Nurse
 
The group footers of Hospital and Doctor have running totals that among other things distinctly counts numbers of patients, and calculates average time spent per patient (hours/patients). These are presented in a table where the patients are divided into 5 different cathegories. Hence, there are 5 different averages. At the end of the report a running total for the whole region is presented. Now, I need to standardize the averages per hospital and eliminate any effect due to cathegory distribution. To be able to do that I need to calculate percentage distribution of each cathegory for the whole region. Later I need to be able to use them in all groups. Since the cathegories (all in one field) are summarized as running totals I can't just use them as they are now in all groups. Now to my question: How can I count the number of each cathegory in a field, and preferably save it as a variable that I later can reuse?
 
Please ask me further questions if this is unclear. I really need help to solve this Confused
Many many thanks in advance,
Anna   
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.