Search code examples
crystal-reports

Include formula field in Crosstab


I want to include my long formula field in a column of my crosstab. But I don't see it as selectable in the crosstab setup screen. How can I include it?

WhilePrintingRecords;
NumberVar i:=Sum({@multiplying_records});
NumberVar t:=i/Sum({%assigning_credit});
t

Solution

  • Technically you can't. But there is a workaround.

    Your Running Total field is evaluated during the Printing phase, but Crosstabs populate during the Reading phase. So your Running Total won't be ready by the time the Crosstab needs it to be.


    The best way around this is to perform the running total's calculations in a custom SQL statement. You can add this from the Database Expert and have SQL do the math for you:

    enter image description here

    This will return a new table in which you can calculate your RT as a field even before it reaches the report. Which means it exists during the Reading phase can be used in a Crosstab.