Print Page | Close Window

Referencing a parameter with multiple values

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3318
Printed Date: 06 May 2024 at 6:18pm


Topic: Referencing a parameter with multiple values
Posted By: Tim Wise
Subject: Referencing a parameter with multiple values
Date Posted: 02 Jun 2008 at 3:58pm
I have a string parameter that has multiple values. How do I reference the list of values in a formula? Currently, I'm only seeing the first value in the list/string.
 
I'd like to use a parameter to form a record selection like
 
{HYP_GLOBAL_SYSTEM_VIEW.HOST} like ["hyp*", "mx*"]
 
where the list ["hyp*", "mx*"] is filled via a parameter.
 
Any pointers are appreciated.
 
PS: I'm using CR 2008.


-------------
--
Tim



Replies:
Posted By: BrianBischof
Date Posted: 02 Jun 2008 at 5:17pm
I'm not sure if you can accomplish what you want to do. It looks like you are trying to do two things at once.

First off, you are asking about using a multi-valued parameter. This is perfectly easy to do in CR. Create the parameter and in the options at the bottom of the dialog box, enable multiple values. The user can enter as many strings as they like.

However, in this question it appears that you want to use the string values to perform filtering on the database. In CR, you would use a mult-value parameter to do exact string matches using the IN operator: {VIEW.HOST} IN {?ParameterName}

But the IN operator doesn't support wild-cards. It can only do exact string matches. I was trying to think of away to trick CR into doing this using string manipulation, but I'm not coming up with anything. Thus, I really don't think it's possible at all.


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: Tim Wise
Date Posted: 02 Jun 2008 at 7:42pm
In CR, you would use a mult-value parameter to do exact string matches using the IN operator: {VIEW.HOST} IN {?ParameterName}
Yep, that works.  
 
I wasn't clear of the type of a multi-valued parameter and how it expanded when used. It turns out that a multi-valued parameter is an array of strings. These are both string arrays:
 
["hdmcjunapp1", "hyp-app"]
["*app*", "mx*"]

Either can be used in a record selection formula:
 
{VIEW.HOST} in {?ParameterName}
{VIEW.HOST} like {?pHostName}
 
IN will do exact mathes; LIKE will match simple patterns. CR translate the LIKE into this:
 
WHERE  ("VIEW"."HOST" LIKE '%app%' OR "VIEW"."HOST" LIKE 'mx%')
 
I'm letting users enter patterns by setting the 'Allow custom values' property of the parameter to true.
 
Thanks for the help!
 
PS: Why does the font of my post get small and turn blue? :-)


-------------
--
Tim


Posted By: BrianBischof
Date Posted: 02 Jun 2008 at 8:25pm
You tested LIKE and this works for a string array? Nice. I had no idea. I'll make a note of it for future reference.

Why is your font blue? I was wondering the same thing myself.  I see this on the forum every now and then and just figured that the user clicked the font button or something. Don't know, it's a packed forum app that I downloaded.


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window