cancel
Showing results for 
Search instead for 
Did you mean: 

Median in crystal reports

Former Member
0 Kudos

How do i get group level median in the report, i tried with Median function but it is giving Median value for the entire report, i want it group level. Thanks for any help

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If I've understood your requirement correctly, I think this can be achieved by the 'Insert Summary' option - choose the field to sumarise, select Median as the calculate method and finally, select a summary location.

It will usually put the field in the footer of the selected location. If desired, move it to the group header.

This should then give Median by group level.

Former Member
0 Kudos

Hi

Thanks, but i tried it already with out success. Ususally that is how i put summary fields group level, but it does not seemed to be working for Median. It still shows the report level median at each group level, i.e. same value is repeated for each group.

I placed two fields in the group summary section 1. Median 2. Sum. Sum is working fine but not the Median

Can i write a formula field to calculate the Median

Thanks

Former Member
0 Kudos

How strange !! I've tried it with a test report with 3 fields in the record: Name, Date, Sales

Group 1 on Name, with count, median and sum figures

Group 2 on Date (in weeks), with median igure

And show all three values in the detail.

The results I get are:

G1: Paul Davis Count 10 Median 250 Sum 2300

G2: 28/03/2010 Median 200

😧 Paul Davis 01-Apr-2010 100

😧 Paul Davis 01-Apr-2010 300

😧 Paul Davis 01-Apr-2010 400

😧 Paul Davis 03-Apr-2010 100

G2: 04/04/2010 Median 250

😧 Paul Davis 04-Apr-2010 200

😧 Paul Davis 04-Apr-2010 200

😧 Paul Davis 05-Apr-2010 100

😧 Paul Davis 05-Apr-2010 300

😧 Paul Davis 06-Apr-2010 300

😧 Paul Davis 06-Apr-2010 300

I have had strange results before when changing the datasource as it hasn't always refreshed properly (and quiting Crystal completely to get it to refresh correctly), but it doesn't sound like the issue here.

-


Think I've cracked it with formula's -


I've created 2 formula as you need one for each seperate group you want the median to appear on. As one of my groups was a date I had to do a conversion (or fiddle, by any other name) as it didn't like a date field in the formula !!

formula 'Group2' contains: cstr({BasicGroups_.Date},"dd-MMM-yyyy")

formula 'Med1' contains: median({BasicGroups_.Sales},{BasicGroups_.Name})

formula 'Med2' contains: median({BasicGroups_.Sales},{@Group2})

I had to change the Group 2 section so it was actually grouped on the 'Group2' formula. This had the effect that the grouping was no-longer in weeks, as it's now a text field.

Hope this makes sense and lets you achieve what you want.

Former Member
0 Kudos

Hi

Thanks a lot for your explanation, actually i was trying to get Median based on a formula which was wrong. I did the same example as you did and it worked like a charm...

Thanks

Answers (1)

Answers (1)

former_member183750
Active Contributor
0 Kudos

Moved to Crystal Reports Design forum...

Ludek