Home / Tech Tip / Crystal Tech Tip / Crystal Reports – Displaying Parameter Values

Crystal Reports – Displaying Parameter Values

Question: I have created several prompts in my report. How do I display what was selected?

Answer: This is a common request. Typically, parameters are used to let someone filter the records that get pulled back. Sometimes they are used in grouping or sorting. In any case, it is always nice to show what is selected on the report. I will go one step further and state that showing everything selected in a cover page is a best practice.

Parameters come in varying levels of complexity. The easiest to display is the single value prompt. Displaying a multi-value or range parameter can be a little trickier.

Single Value Parameters: These can just be dropped into the report from the Field Explorer. They will display just as any other field. You can format them as you like. It is good practice to add labels in from of the parameter fields using text boxes. You can go one step further and insert the field into the text box. I suggest making all of the formatting changes you want before moving the field into the text box. You can still format the field once it is in a text box. However, you will only be able to change text formatting like bolding and color.

Another way to display single prompt values is to incorporate them into a formula. This is the same thing as concatenation. You are just adding the field to text with an ampersand (&). You can use the ToText() function to manipulate the formatting. The problem with doing things this way is that once the formula field is placed into the report you can only make formatting changes to the whole formula. With the method above, the text inside the text box and the parameter value can be formatted independently.

Range Value Parameters: When you choose a parameter to allow a range of values, you are forced to use formulas in order to display the values. Just placing them on the report will only display the very first choice. The most typical range parameter is a date range. When working with these, you generally just want to display the lower and upper ends of the range. This can be done by using the Minimum() and Maximum() functions. But, the real power comes from using the ToText() function in conjunction with theses two functions.

Once you have the formula created, you can place it in the report. Again, if you create one long text string as your formula, you will only be able to format the whole thing once it is placed on the report. If you want to use separate formatting for the minimum and maximum values, create two formulas.

For example, to display a date range for records chosen such as “for records between 10/01/2004 and 10/31/2004” you would use two formulas and a text box:

Formula 1: ToText( Minimum( {?My Date Range Parameter}), “dd/MM/yyyy”) Formula 2: ToText( Maximum( {?My Date Range Parameter}), “dd/MM/yyyy”)


Multi Value Parameters: Multi-value parameters are the most difficult to display. This is because the values are stored as an array. Therefore, you need to follow the same logic you would to display all values in an array. Luckily, Crystal comes with an easy method for displaying the values of a string array, the Join() function. This built-in function lets you separate all of the values in the array. However, this only works with string parameters. If you are using any other type, you will need to loop through the values and add them to a variable – see example formula below.

Example Formula (Number-based Parameter)

Local numberVar i; Local stringVar sParameter := “”; For i := 1 To UBound({?My Parameter}) Do     //loop through the whole parameter     sParameter := sParameter & “, ” & ToText({?My Parameter}[i], “0”)  //append the current value ; Mid(sParameter, 3)  //remove the first comma and space

About ckruger

Check Also

Crystal Reports – In Row (Detail) Charting

Question: Wouldn’t you like a way to visually show/compare your data right at the detail-level? …


  1. Hi Thanks for the above formula, it works perfectly on my report where I run a parameter to select Emp. Id. Nos. and show the selected records in the Report Header.

    I have about 200 employee id numbers and usually only select up to about 5 for my report, but there are times when I want to select the all and of course there is not enough room in the report header to display them all, so I would like to show a short sentence, e.g. “All Records Selected” can you add this kind of Text to the formula.


  2. Very nice, thank you, the number based parameter formula helped me solve a problem I was having. I needed to play w syntax d/t word wrapping you have above.

    Local numberVar i;
    Local stringVar sParameter := “”;
    For i := 1 To UBound({?Param})Do //loop through the whole parameter
    sParameter := sParameter & “, ” & ToText({?Param}[i], “0”); //append the current value ;
    Mid(sParameter, 3) //remove the first comma and space

  3. Priyanka upadhyay

    I am working on crystal report right now. I am getting error for record selection formula field. Can you tell me if any mistake is in this coding below.

    PAT_ENC.ENC_TYPE_C} = “50” // 50- ApPointmeNT visit
    {PAT_ENC.APPT_STATUS_C} = 3 //3-canceled

    // // This parameter is used to get values about perticular Cancellation Reason.
    // //This parameter get value from PAT_ENC.CANCEL_REASON_C column and get result for pertiluar reason(s).
    // // you can choos emultiple values too.
    // //If you like to get All reasons Results you can choose 0 and get all records. 0 = All
    ( {?CancelReason}=0 OR {ZC_CANCEL_REASON.CANCEL_REASON_C} in {?CancelReason} )

Leave a Reply

Your email address will not be published. Required fields are marked *