Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: coefficient of dispersion Post Reply Post New Topic
Author Message
dustbun
Newbie
Newbie


Joined: 19 Jan 2009
Online Status: Offline
Posts: 4
Quote dustbun Replybullet Topic: coefficient of dispersion
     Posted: 19 Jan 2009 at 3:03pm
Part of the formula is to take the absolute value of the sale ratio minus the median ratio, per subdivision.
I am able to get the median ratio by using a running total (or a formula), but I am unable to figure out how to compare it to each detail line and calculate the absolute difference (abs(ratio – median ratio) and then add the values up to get the sum of the absolute difference in the group footer. 
 
I have tried this every which way I can think of (i.e., sub-reports, passing the value back to the main report), but with no success.  I am brain dead and weary.  Any suggestions would be appreciated.
 

Subdivision
PID
Ratio
Median
Absolute Difference
Sum of Absolute Difference Per Subdivision
1082
1
0.933
0.8845
0.0485
 
1082
2
0.887
0.8845
0.0025
 
1082
3
0.882
0.8845
0.0025
 
1082
4
0.878
0.8845
0.0065
0.06
1083
5
0.854
0.9145
0.0605
 
1083
6
0.975
0.9145
0.0605
0.121
1085
7
0.942
0.918
0.024
 
1085
8
0.891
0.918
0.027
 
1085
9
0.918
0.918
0
0.051
1432
10
0.892
0.819
0.073
 
1432
11
0.801
0.819
0.018
 
1432
12
0.905
0.819
0.086
 
1432
13
0.819
0.819
0
 
1432
14
0.812
0.819
0.007
0.184

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 Jan 2009 at 6:15am
I would have thought that a subreport might work.  Have the subreport calculate the median and set a shared variable so that the main report could use it...think of it as the formula. I only propose this, as the easiest way to figure the median is all the records first, but Crystal basically is reading 1 detail record at a time...except in a subreport, then it is one detail, and all associated records, but you probably already knew that.
 
I don't know if you have tried that, but that would have been my plan of attack.
 
Hope it helps.
IP IP Logged
dustbun
Newbie
Newbie


Joined: 19 Jan 2009
Online Status: Offline
Posts: 4
Quote dustbun Replybullet Posted: 20 Jan 2009 at 2:24pm
Worked on it all day, but I have it.  Your answer got me to try it again.  It was a little more complicated than that, but I got there.  There is a long explanation, but to keep it short, I was able to calculate using the subreport, but I had issues summarizing the totals on the group footer.  I ended up creating a variable and resetting after each group. 
 
Thank you!!!!
IP IP Logged
SThornsberry
Newbie
Newbie
Avatar

Joined: 13 Apr 2010
Online Status: Offline
Posts: 1
Quote SThornsberry Replybullet Posted: 13 May 2010 at 10:43am
I am having the same issues working on the COD.  Could you send me some instruction or sample code/report explaining your solve of this.
 
Thanks
Shane Thornsberry
Shane Thornsberry
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