Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kswindlehurst
Contributor III
Contributor III

Parameterized variable for set analysis

I'm trying to build a parameterized variable that produces a different set analysis filter for a bunch of straight table expressions.

This is the literal expression I start with:

=ONLY({<Indicator={'Maximum Vacuum (Postop)'}>} Value)

I use $ substitution:

=ONLY({$(vtest(1))} Value)

but get nulls in the chart.

Definition of vtest:

<Indicator={' & chr(39) & SubField('$(eIndicatorSelectionsArray)','|',$1) & chr(39) & '}>

Trying to troubleshoot, I put quotes around the expression:

='ONLY({$(vtest(1))} Value)'

then the result in the chart matches the original expression text: ONLY({<Indicator={'Maximum Vacuum (Postop)'}>} Value)

so the SubField function and $Expansion are working fine. 

Can anyone see what I'm missing?

Thx

-Kevin

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

A good technique to debug these rather comlplex substitutions is to simulate them by hand.

For example

=ONLY({$(vtest(1))} Value)

with vtest containing

<Indicator={' & chr(39) & SubField('$(eIndicatorSelectionsArray)','|',$1) & chr(39) & '}>

and nothing else, first expands into:

=ONLY({<Indicator={' & chr(39) & SubField('Some|string|that|doesnt|really|matter','|',1) & chr(39) & '}>} Value)


which isn't really a regular set analysis spec. The quotes turn it into a mess. Marcus has a good suggestion, but I think that this vtest content may work even better (no double quote pairs):


<Indicator={"$(=SubField('$(eIndicatorSelectionsArray)','|',$1))"}>


Best,


Peter


PS Sorry about the font size, but I couldn't get the examples to stand out and stay on the same line at the same time...


View solution in original post

7 Replies
tresesco
MVP
MVP

Somehow it's an expansion issue I guess. May be missing quotes in variable declaration or improper '='. Could you share your sample qvw?

marcus_sommer

Try it with:

<Indicator={"=chr(39) & SubField('$(eIndicatorSelectionsArray)','|',$1) & chr(39)"}>

If you used your expression within a table-chart and left the label for the expression blank you could see how qv interpreted the expression.

- Marcus

kkkumar82
Specialist III
Specialist III

Hi,

You can create a parameterized variable for the expression you have written and use it in set analysis.

Variables with Parameters

Hope this may be useful for you, observe the variables in the variable overview window.

Thanks

Kiran kumar

Peter_Cammaert
Partner - Champion III
Partner - Champion III

A good technique to debug these rather comlplex substitutions is to simulate them by hand.

For example

=ONLY({$(vtest(1))} Value)

with vtest containing

<Indicator={' & chr(39) & SubField('$(eIndicatorSelectionsArray)','|',$1) & chr(39) & '}>

and nothing else, first expands into:

=ONLY({<Indicator={' & chr(39) & SubField('Some|string|that|doesnt|really|matter','|',1) & chr(39) & '}>} Value)


which isn't really a regular set analysis spec. The quotes turn it into a mess. Marcus has a good suggestion, but I think that this vtest content may work even better (no double quote pairs):


<Indicator={"$(=SubField('$(eIndicatorSelectionsArray)','|',$1))"}>


Best,


Peter


PS Sorry about the font size, but I couldn't get the examples to stand out and stay on the same line at the same time...


kswindlehurst
Contributor III
Contributor III
Author

Kiran,

I already have a parameterized variable defined: vtest(i)

The problem seems to be a scope\evaluation issue. 

kswindlehurst
Contributor III
Contributor III
Author

Peter,

The problem seems to be a scope\evaluation order issue.  To get the variable to reevaluate the parameter each time it's called, I can't have an = starting the variable definition.  But I do still need to evaluate the SubField function somewhere, which means the evaluation command has to be at least a level above i.e. exactly like your last suggestion, a $(=expression) surrounding a $(substitution).

Thank you!

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Correct analysis. you're on to it.

Good luck, and enjoy QlikView and the Qlik community.

Peter