PREVIOUS() function in Crystal Reports

By | May 31, 2023

In the Sage X3, we have various standard reports for almost every screen which are developed in Crystal Report. Also we can develop new customized crystal report as per the client’s need.

For one of our client we have developed a report that contains all the information related to Work Orders (report is printing in excel format) and there was a requirement from the client that if the Operation Status is closed for the previous line then the Planned Qty of the previous line should be printed in a “Previous Operation Qty” field of current line.

For this requirement, we have used the Previous() function in Crystal Report formula.

To achieve the above requirement follow the below steps:

Step 1: Create a formula ‘fm_close‘ for previous line’s status (whether it is close or not)

New Stuff: How to conditionally format fields using the Highlighting Expert in Crystal Report

Formula fm_close
Formula fm_close

Step 2: Create another formula ‘Pre_Op_Qty‘ to retrieve the last line’s planned qty (if the status is closed for last line else print 0)

Formula Pre_Op_Qty
Formula Pre_Op_Qty

Step 3: Drag and drop this formula ‘Pre_Op_Qty’ wherever you want to add in report.

Output
Output

Refer the above screenshot in which you can check, by using previous function, we have printed planned quantity of previous line in the next line only if the operation status of previous line is “Closed”.