Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Unable to use a variable in a Summary


My report includes a formula that generates either a 0 or1,  which I hoped would  help me summarize my count of distinct patient days.

Here is the formula:

if (previous({Command.PAT_ID}) <> {Command.PAT_ID}) OR ( previous({Command.PAT_ID}) = {Command.PAT_ID} AND previous ({@Date}) <> {@Date}) then 1 else 0

The variable works fine in the detail section in that it correctly displays either the 0 or 1 as expected.

The problem is that when I select the Insert Summary tool,  this variable is not available to use in a summary. I 'googled' the issue and found similar situations but don't fully grasp what I must do to resolve this (apparently Crystal sees this as a constant?). Any suggestions would be much appreciated.


Hi Dave,

You cannot summarize formulas that include the previous() function.

1) Create a formula with this code;

{Command.PAT_ID} & {@Date}

2) Go to the Insert Summary Option > Choose this formula field as the 'Field to Summarize' > Choose 'Distinct Count' as the Summary Function > Under Summary Location, choose 'Report Footer' if you wish to create a Grand Total or 'Group#' if you wish to place this at the Group Footer.


0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question