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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinct Sum???? Crystal XI R2

Status
Not open for further replies.

pungigis

Programmer
Dec 5, 2007
71
US
Can I get a sum of dollars based on the distinct count of another field??? Example...

120.00 123
1621.73 456
543.40 789
175.00 012
175.00 012

From the above I am seeing 2635.13 5, I would expect to see 2460.13 4.


 
I think the below may do what you need.


//{@add on distinct}
numbervar sm;
IF ({table.field})=previous(table.field}
then sm := sm
else sm := sm + {table.amount}


//{@display distinct}
numbervar sm;
sm


if you are going to sum on multiple groups, you would likely need a reset formula also

//{@reset distinct}
numbervar sm := 0;



It may also be possible using a running total.
 
If you use a manual running total using the above formulas, add "whileprintingrecords;" to the beginning of each formula. Otherwise, you could insert a running total that does a sum of the first field, and evaluates on change of the second field. Reset never or on change of group, depending upon your needs, but place the running total in a footer section.

-LB
 
doh!
thanks lbass
i should remember that by now.
the folly of my memory!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top