Print Page | Close Window

Formula field syntax for parameters

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=22894
Printed Date: 02 May 2024 at 3:25am


Topic: Formula field syntax for parameters
Posted By: Carol1
Subject: Formula field syntax for parameters
Date Posted: 06 Sep 2020 at 4:15pm
Hi.
I have multiple optional parameters in a report and want to include them in the report header. I've inserted a text box and listed the parameters, and I want the parameter values to appear against the related text for each parameter or the words 'not selected' if no parameter values are entered, eg:
'Date Range: 1/9/20 to 7/9/20' or 'Date Range: not selected'.
To achieve this outcome, I believe that I must create a formula field for each parameter, incorporating the parameter field into an If…Then…Else statement, then insert the formula field into the text box. However, I’m struggling to create the correct syntax for the formula.
Following is an example where the error message highlights the word ‘is’ and states that the keyword ‘then’ is missing:
(
if {?Submission Reason} is true
then {?Submission Reason}
else "not selected"
)
If I replace ‘is’ with ‘=’, then the parameter field is highlighted with a message indicating that a boolean array is required. I’ve tried several other variations but just continue to get different error messages.
Suggestions on the correct syntax would be greatly appreciated.
Cheers ...



Replies:
Posted By: kevlray
Date Posted: 08 Sep 2020 at 5:37am
Use the HasValue function.  I should parse the parameter correctly to see if a value has been entered.


Posted By: Carol1
Date Posted: 17 Sep 2020 at 3:57pm
Thank you, kevIray.
I eventually came up with the following syntax, which works perfectly:
(not HasValue({?Parameter}) OR {TABLE.FIELD} = {?Parameter})
I appreciate your assistance.
Cheers,
Carol



Print Page | Close Window