Print Page | Close Window

Sort by Embedded Summary

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22500
Printed Date: 27 Apr 2024 at 6:14pm


Topic: Sort by Embedded Summary
Posted By: brain
Subject: Sort by Embedded Summary
Date Posted: 18 Nov 2017 at 2:45am
Crosstab report.
Row by customer name.
Columns by month.
Also a grand total column
Two summarized fields: Profit & TotalRevenue
I added Embedded Summary to divide Margin by TotalCharge to produce margin: profit as a percent of total revenue by customer.

Here is the embedded summary calculation formula:

If
     GridValueAt(CurrentRowindex, CurrentColumnIndex, CurrentSummaryIndex-1) = 0
then
     0
else
     (GridValueAt(CurrentRowindex, CurrentColumnIndex, CurrentSummaryIndex-2)
     /
     GridValueAt(CurrentRowindex, CurrentColumnIndex, CurrentSummaryIndex-1) )
     *100

This all works, but how do I now get my rows to sort by the profit % (i.e. by the Embedded Summary, or at least by the same formula)? I tried adding a formula Profit/TotalRevenue to the report (not to the Crosstab) on the theory that I could then sort by it, but that generated the overall margin% for all customers combined and put it on each row, rather than calculating the margin within each row.



Print Page | Close Window