• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1360
  • Last Modified:

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
  • 2
1 Solution
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 businessobjects.com 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.


Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now