Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Formula field syntax for parameters Post Reply Post New Topic
Author Message
Carol1
Newbie
Newbie
Avatar

Joined: 03 Sep 2020
Location: Australia
Online Status: Offline
Posts: 6
Quote Carol1 Replybullet Topic: Formula field syntax for parameters
    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 ...

Edited by Carol1 - 06 Sep 2020 at 4:35pm
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet 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.
IP IP Logged
Carol1
Newbie
Newbie
Avatar

Joined: 03 Sep 2020
Location: Australia
Online Status: Offline
Posts: 6
Quote Carol1 Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.062 seconds.