Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Filtering data in subreport based on formula in ma Post Reply Post New Topic
Author Message
Jeremy Duval
Newbie
Newbie


Joined: 26 Feb 2008
Location: United States
Online Status: Offline
Posts: 2
Quote Jeremy Duval Replybullet Topic: Filtering data in subreport based on formula in ma
     Posted: 26 Feb 2008 at 7:16am
I'm trying to create a report that includes only records less than or equal to the 90th percentile of a number field of the full set.
 
My inclination was to use a main report that calculated the 90th percentile value in a shared variable, then use that shared variable in the selection formula of a subreport (placed in the main report footer).
 
Whenever I do so, the selection formula of the subreport doesn't compile, saying the shared variable must be evaluated later.  I thought that was the point of having the subreport, but then again, subreports are new to me.  Any thoughts?
 
Thanks immensely,
 
Jeremy
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 26 Feb 2008 at 11:53am
Can you calculate that 90th percentile in SQL in a Command?  At that point you'll have the data in the main report without having to calculate it in a shared variable so it won't throw an error.
 
-Dell
IP IP Logged
Jeremy Duval
Newbie
Newbie


Joined: 26 Feb 2008
Location: United States
Online Status: Offline
Posts: 2
Quote Jeremy Duval Replybullet Posted: 26 Feb 2008 at 12:07pm

Crystal is really great in that it has the PthPercentile() function.  I don't know of a comparable function in Transact-SQL.

In any case, with some advice from a collegaue I got it to work.  I removed the shared variable, and simply used the PthPercentile function in a formula in the main report without declaring a variable.  I created a parameter in the subreport.  In the subreport links, I used the PthPercentile formula field as the field to link to and set the newly created subreport parameter.  Then I referenced the parameter in the subreport selection formula.  Voila, my results included only records less than the 90th percentile!
 
Sorry if this is real elementary - this is my first need to filter records based on a calculation evaluated within a report....
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