How can I use variables in crystal report and what is the diffrence between formula and variables in crystal report?

I have design a report which has parent child data. I am displaying my parent record in group header and child data in detail section. Now I want to do some subtotals in child data but this subtotal is based on some condition. Like if Currency is in CDN then add amount in VarCDN or if currency is in USD then add total in VarUSD. And I want these totals to be reset on group change. My problem is I dont know the sequance, step by step process to get the result. I dont have any link for crystal report help. I am little bit confuse between variables and formula. Every time I try to write formula I get the following error:
if {KHDaily1;1.PaymentMode} = "1 CASH CDN" then
numberVar cscdn := csdn + {KHDaily1;1.Part_Amt} ;
A number, currency amount, boolean, date, time, date-time, or string is expected
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Variables are things which can be used in multiple spots inside of Formulas. Variables are not required to make a formula in Crystal. I've always had a little trouble with global variables (which I think must be your csdn field), especially when doing a running total. I'm just not good at them. :-) What you could try.
1 formula (let's call it ONE) doing:
if {KHDaily1;1.PaymentMode} = "1 CASH CDN" then {KHDaily1;1.Part_Amt} else 0

2nd formula would be sum(@ONE, @GroupName).

Crystal will automatically reset totals when you place them at the group level, so you might not need a variable at all.

Good luck, hope this helps.
khalidsuhailAuthor Commented:
2nd formula would be sum(@ONE, @GroupName).
What do you mean by @GroupName?
Is it 2nd parameter in SUM ?
Can you explain ?
Do you know any site for crystal help ?

Hi Khalid,

The 2nd formula syntax allows you to summarize. If you were to place your ONE formula into the detaul and the output looks like the following...

your TWO formula could be inserted in a group header or footer sum(@ONE, groupnamehere) and you would end up with output of 600 (300+200+100).

So far this is actually the best place I have found for Crystal Help. You can try to look on the website, but I usually end up not finding what I need there.
To summarize, I find it easier to drop the field or the formula onto the report in the detail section
Right click it
Choose the footer I want it in.  It defaults to REPORT FOOTER but you probably want it inyour group footer.

As above create another formula to get the US dollars.


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
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
DB Reporting Tools

From novice to tech pro — start learning today.