Sum Distinct Records not duplicate Records

I currently have a formula as such

if {@grouporder_desc} = 'Non-Rent Other Account' then {glf_ldg_acc_trans.AMT1} else 0

I need a distinct SUM on glf_ldg_acc_trans.transnbr

Sorry not sure how to do that.

Thanks
NewFocusConsultAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
If you are grouping on transnbr then you can simply create a Running Total that evaluates on group change.

Otherwise, you could create a global variable (delimited string or an array) that stores all distinct transnbr values encountered (your formula would check for each row if the transnbr is in already in the string or array variable.  If it is, ignore it -- if it isn't, add it to the string/array and add the value to be summed into a numeric variable.

If the number of distinct values is too large for a string or array variable in Crystal, there's one other option, but let's start with the simple options... :)
0
NewFocusConsultAuthor Commented:
IdoMillet

Thank you for your response, unfortunately a Running Total won't work as the total will be placed in the page header not footer or group footer.

Not sure how to use variables, would love an example please?
0
James0628Commented:
Trying to use variables will have the same problem as using a running total.  The variables will be updated as the records are processed, so you won't have a total until the report gets to the last record in the group/report/whatever.

 Your only option in the report may be to use a subreport in the page header.  The subreport would read the same data and produce your total.  The first question would be, if your report is longer than a page, can you get the subreport to produce a total for just the data that's on the current page (assuming that you're looking for a page total)?

 If the report is using something like a stored procedure or view, where you control the query, then another option might be to generate the totals in the query (this may also depend on what's on each page of the report).

 James
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

James0628Commented:
Just curious.  What was your solution (since I posted a couple of possibilities) ?

 James
0
NewFocusConsultAuthor Commented:
Sorry - Sub Report will work as the top group is the account.

Thanks
0
James0628Commented:
OK.  Thanks.  FWIW, I imagine that a subreport was what Ido was alluding to in his last sentence, but I got to it before he did.  :-)

 James
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.