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

Posted on 2008-11-13
Last Modified: 2013-11-16
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
Question by:khalidsuhail
    LVL 14

    Expert Comment

    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.

    Author Comment

    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 ?

    LVL 14

    Expert Comment

    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.
    LVL 100

    Accepted Solution

    To summarize, I find it easier to drop the field or the formula onto the report in the detail section
    Right click it
    Click INSERT --> SUMMARY
    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

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now