Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

X as percent of Y (runtime grouping)

Status
Not open for further replies.

drdad5727

Programmer
Feb 28, 2005
28
US
I want to present, in a Group Footer, the percent that(the sum of) X in that group is of (the sum of) Y in that Group. Now that should be calculated by

Sum(X,group)/Sum(Y,group)

Trouble is, I want to change the grouping condition at run time.

(This is Crystal XI, VS2008, by the way.)

Now, if I use the Summary Expert to insert a summary into a Grouping Footer and then change the grouping condition at run time, it (Crystal) automatically changes summary formula. That is, it changes
Sum(X,group1)
to
Sum(X,group2)
when group1 is defined as the grouping condition in the .rpt and I change to group2 at run time.

The summary expert will allow me to insert "sum(x,group) as percent of total(x)" but not that's not what I want.

So, the question is: Is there a way to code "X as a percent of Y in this group" and change group conditions at run time?
 
Not sure how you are changing the group at runtime, but if you wanted to do this within Crystal, you could set up a parameter for the group, and then use this in a formula as in:

if {?Parm} = "Group1" then
{table.field1} else
if {?Parm} = "Group2" then
{table.field2}

Then you would group on this formula and use this as the group condition in your percentage formula. Maybe you can adapt this approach for your purposes.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top