cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

If... in - multiple values

Former Member
0 Likes
915

Hi,

I have the following statement in a formula:

if not ({pool_bearbeit.typ} in [200,401,409,410,411,413,420,450]

The numbers are processes, constantly added or deprecated.

To make this more manageable and visible, I'd like to be able to dynamically display these numbers in the page header, to confirm to the User what is actually being chosen.

I believe I've seen code where a single value is entered as a parameter, and then passed through to the report, invisible to the User, but the setup eludes me, and I don't know if that can be done for multiple values.

What method can I use to do this?  I imagine it's possible, but the syntax eludes me.

I would need an option for both numerics and strings.

Thank you.

View Entire Topic
former_member292966
Active Contributor
0 Likes

Hi Matthew,

You can create a parameter and set it to allow multiple values.  Change your formula to use the parameter instead of the array. 

You can create a formula to display the array like: 

NumberVar i;

StringVar myArray;

i := 1;

myArray := "";

While i <= Count ({?My Parameter}) Do

    (

    myArray := myArray & ToText ({?My Parameter} [i], 0, "") & ", ";

    i := i + 1;

    );

//Removes the trailing comma

myArray [1 to Length (myArray) - 2];

The Count ({?My Parameter}) is the number of elements in the parameter.  So it just loops through all of the numbers in your parameter, converts them to a string and lists them out. 

Good luck,

Brian

Former Member
0 Likes

I don't want Users to have to select the values from a dialog box.

I've seen (in fact our vendor uses it often) where the parameter value is set, automatically passed, and the parameter dialog box isn't even displayed.

DellSC
Active Contributor
0 Likes

What software package is your vendor providing?  They are probably setting the parameter value automatically in their code and you would have to find some way to hook into that mechanism.  So, you'll have to go to them to ask this question because we have no way of knowing how they've done this particular task through the SDK and what types of values they've set it up to accept.

If you can't do this through them then I may have another way of doing this:

1.  Create a formula that is just a string value.  In your example above, it would look like this (note the final comma on the end!):

{@Values}

"200,401,409,410,411,413,420,450,"

2.  Create a formula to display this list correctly:

{@ShowValues}

left({@Values}, Length({@Values} - 1)

3.  Change the If statement to this:

if InStr({@Values}, {pool_bearbeit.typ}+",") = 0

To update this list, you only have to change it in {@Values}.

-Dell

Message was edited by: Dell Stinnett-Christy

DellSC
Active Contributor
0 Likes

My edit isn't showing up - the if statement should b:

if InStr({@Values}, ToText({pool_bearbeit.typ}, 0, "") + ",") = 0


This will take care of instances where you have numbers "inside" other numbers, such as if you have a value in {pool_bearbeit.typ} of 20. Since "20"  is in part of 200 it's data would not be included in the "then" portion of the If statement.  Having the comma on the end of the field value when you're searching prevents this.


-Dell

Former Member
0 Likes

Thank you, Dell.  I will give this a shot.