3 Replies Latest reply on Apr 30, 2013 10:07 AM by philmodjunk

    Sub-summary and calculation

    justjoker

      Title

      Sub-summary and calculation

      Post

           Hello,

           I think it's easy but I can't figure out how to ...

           I've got a table with CountWin (>=0) and CountLoss (<0) transactions. I count them separately and got a calculation field "Win/Loss Ratio"=CountWin/CountLoss.

           When I put CounWin and CounLoss on Sub-summary part of the layout sorted by other fields I see correct results, but CountWin/CountLoss field that is also on that sub-summary shows the result for all records but not sorted ones.

      Example:

           Transaction A (3)  CountWin=2   CounLoss=1 CountWin/CountLoss=1.5 (should be 2/1=2)

           100

           -50

           40

           Transaction B (2) CountWin=1 CounLoss=1  CountWin/CountLoss=1.5 (should be 1/1=1)

           50

           -25

           Total: 5                  CountWin=3 CounLoss=2  CountWin/CountLoss=1.5 (correct)

            

           What am I doing wrong?

           Kind regards,

           Sergey

            

        • 1. Re: Sub-summary and calculation
          philmodjunk

               Summary fields produce different totals depending on the context in which you use them. In a calculation, the summary field returns a value based on the entire found set--not the subsets produced when you sort records in a sort order that includes the "when sorted by" field specified for a sub summary layout part.

               To get those sub totals to use in a calculation, use the GetSummary ( SummaryField ; BreakField ) function. For "break field", select the same field that you have selected as the "when sorted by" field in your sub summary layout part.

          • 2. Re: Sub-summary and calculation
            justjoker

                 Thanks. But what should I do when I sort by several fields at the same time?

                 Sergey

            • 3. Re: Sub-summary and calculation
              philmodjunk

                   It doesn't matter. What matters is that your break field match the "sort by" field setting in the sub summary part that shows the same sub total you want to use in your calculation. (Note that you don't specify multiple fields for the same sub summary part even though you may sort on multiple fields to set up the report.)