Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: crosstab average by count of cols Post Reply Post New Topic
Author Message
TruSmith
Newbie
Newbie


Joined: 13 Jun 2012
Online Status: Offline
Posts: 5
Quote TruSmith Replybullet Topic: crosstab average by count of cols
     Posted: 13 Jun 2012 at 2:28pm
I am trying to average an annual report in a crosstab.
 
The problem is the average is worked on the number non-zero rows.
 
So, if no data in <say> November, the calculation is done dividing by 11.
I need the average to divide by 12 - as in months in the year.
Rather than an average of months where something happened.
 
How can i achieve this please?
 
I am even happy to hardcode the number 12 somewhere, and select only 12 month periods, but where/how to put it
TruSmith
IP IP Logged
TruSmith
Newbie
Newbie


Joined: 13 Jun 2012
Online Status: Offline
Posts: 5
Quote TruSmith Replybullet Posted: 17 Jun 2012 at 11:44am
I wonder if my lack of responses suggests this is a no go?  Can it not be done?
TruSmith
IP IP Logged
TruSmith
Newbie
Newbie


Joined: 13 Jun 2012
Online Status: Offline
Posts: 5
Quote TruSmith Replybullet Posted: 18 Jun 2012 at 2:21pm
SORTED !Clap
 
I put this into my Display String...
 
Global NumberVar gnReportAvg;
gnReportAvg := CurrentFieldValue /12;
ToText(gnReportAvg, 0)
 
The CurrentFieldValue was the bit i was looking for.
TruSmith
IP IP Logged
miguelm3
Newbie
Newbie
Avatar

Joined: 15 Sep 2012
Online Status: Offline
Posts: 1
Quote miguelm3 Replybullet Posted: 15 Sep 2012 at 2:50am
Hey!

You are great man!
In my case I had to count the columns and not force the number beacuse the columns depends on parameters.

The Average function it's no good (problem not counting zero column that really are null), so I used Sum, and then in the Display String (I discovered thanks to you :) ) I put:

totext( CurrentFieldValue /
({?Periodo_Hasta}-{?Periodo_Desde}+1) ,
'###.00' )


It's not working if you want to list the month 11, 12, 1, 2 but I had to make o function or someting like that, meanwhile it's working now that we are in september.


Edited by miguelm3 - 15 Sep 2012 at 2:51am
Maik
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