Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
UrsulaWhite
Contributor II
Contributor II

Passing multiple parameter values through a variable

Would like to pass through multiple values through multiple variables in the script editor as follows:


 Set vMeasure =
(Count({$<[Field1]={'0-35'},
 [Field2] = {$1},
 [Field3] -= {$2}
 [Field4] -= {$3}   
 [Field5]={$4}>}
 measure)
/Count({$<[Field1]={'0-35','>35'},
 [Field1] = {$1},
 [Field2] -= {$2}
 [Field3] -= {$3}     
 [Field4]={$4}>}
measure));
 
Where
Field1 values are Field1Value1 and Field1Value2,
The Field2 value is Field2Value1,
The Field3 value is Field3Value1,
The Field4 value is Field4Value1.


If there is only one value this works as follows:
$(vMeasure('Field1Value1','Field2Value1',''Field3Value1,'Field4Value1')
I have tried putting in two values for a field, but had no success.
$(vMeasure(('Field1Value1','Field1Value2'),'Field2Value1',''Field3Value1,'Field4Value1')
Is it possible to do this?  If so how does the syntax work?

Labels (1)
2 Solutions

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

There is no way I've found to pass a comma as part of a parameter. It's always interpreted as a separator no matter the syntax.  What I've done as a workaround is to use a proxy character like '|' and replace() it with a comma in the variable expression.

-Rob

View solution in original post

bbongagus
Contributor II
Contributor II

Or you can declare other variable with that values and pass variable name like parameter, then in your function you can use it like 

$($1)

Example:

vValues = {'Field1Value1','Field1Value2'}

vMeasure(vValues)

vMeasure = Sum({<[Field] = $($1)>} [MeasureField])

View solution in original post

5 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

There is no way I've found to pass a comma as part of a parameter. It's always interpreted as a separator no matter the syntax.  What I've done as a workaround is to use a proxy character like '|' and replace() it with a comma in the variable expression.

-Rob

UrsulaWhite
Contributor II
Contributor II
Author

Do you mean in the Set Analysis Expression you would use the following:
$(vMeasure(('Field1Value1'|'Field1Value2'),'Field2Value1',''Field3Value1,'Field4Value1')
 
and in the Variable vMeasure the replace() function like below?
Replace( [Field4]={$4}, '|',',')
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Yes, that's the concept.

-Rob

bbongagus
Contributor II
Contributor II

Or you can declare other variable with that values and pass variable name like parameter, then in your function you can use it like 

$($1)

Example:

vValues = {'Field1Value1','Field1Value2'}

vMeasure(vValues)

vMeasure = Sum({<[Field] = $($1)>} [MeasureField])

Rozgonyi
Partner - Contributor II
Partner - Contributor II

Good morning, 

I must solve the following and I do not know how to write it. I have already tried a lot of variants and just do not get on. Could someone please help me.

=Replace($(vSample1($('1000/10ML'|'1000/5ML','PH5','VALID'))),'|',',')

=$(vSample1((=Replace('1000/5ML'|'1000/10ML','|',',')),'PH5','VALID'))

 

Thank you very much.