How to call on a Variable in a formula.

Posted on 2011-04-25
Last Modified: 2012-12-26

I am using this to total some information and eliminate duplicates. However, I need to use the totals being produced within the footer section in a formula. If I browse that field it shows zero, even though when placed in the footer it does give the correct total..

Also, I also need to be able to average an unsuppressed field in my details. Can this be done using the same method, variables?

Thanks.. P.S. I am very much not liking having to create all these fomulas just to sum my unsuppressed fields.. If there is an easier way to do this please someone tell me! I can't figure out why Crystal would not have incorporated this feature! :(

Question by:SeyerIT
    LVL 100

    Assisted Solution

    >> I can't figure out why Crystal would not have incorporated this feature!
    If you can tell them how to do it then I am sure they would be happy to incorporate it into the next version.

    Footer formula
    Global NumberVar Group1Total;
    Global NumberVar Group3Total;
    Global NumberVar GrandTotal;
    Use the variable/total you want

    LVL 34

    Accepted Solution

    Another option would be to use running totals.  You have more control over those than regular summaries.  Right-click on the field/formula in the detail section and select Insert > "Running Total".  Under Evaluate, click "Use a formula" and then click the formula (X+2) button and enter the reverse of your suppression formula:

    NOT (Not OnFirstRecord And {@CurrentCost} = Previous({@CurrentCost}) And
     {BAQReportResult.JobMtl.AssemblySeq} = Previous({BAQReportResult.JobMtl.AssemblySeq}))

     If it's a group total, use the "On change of group" option under Reset to reset that total for each new group.

     CR will probably put the running total field in the detail section.  Just move it wherever you want it.

     I wasn't sure if you'd be able to use OnFirstRecord or Previous in a running total like that, but I just tried it here and it seemed to work fine.

     You can do the average the same way.  CR seems to only include the "non-suppressed" records when calculating the average.

     You still have to enter the reverse of your suppression formula in each running total, but maybe you'll find that easier than using formulas and variables.

    LVL 2

    Author Comment

    mlmcc: I only wish I knew more about these programs to make such a suggestion :) I know how I would like to see it work.. Probably have a checkbox in the Section Expert that would say something like, checked to ignore suppressed values in calculations or unchecked to calculate suppressed values.. It just seems like that would save a lot of time.. I guess it will be different as I get to know the software better..

    Aside from my bickering about the software :)

    James your method is definitely easier to work with and for me to understand. Nonetheless either will work.. At least I know there is an alternative to the variables.. I'm sure in due time I will have a much better handle on those though..

    Let me work with this now for a bit and I'm sure I will be back later today with more questions... Creating this report is definitely proving to be a challenge.. But I will say that I am learning A LOT in the process!

    Thanks again guys!
    LVL 34

    Expert Comment

     > Probably have a checkbox in the Section Expert that would say something
     > like, checked to ignore suppressed values in calculations or unchecked to
     > calculate suppressed values.

     That's actually an interesting idea.  I don't know how often it would really be needed by CR users in general, but it seems doable and would certainly be useful at times.

     FWIW, there are some things that running totals just can't handle, so if you work with CR very much, you'll probably need to use variables sooner or later.  But if running totals give you what you need, I see no reason not to use them.


    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    This video discusses moving either the default database or any database to a new volume.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 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

    15 Experts available now in Live!

    Get 1:1 Help Now