Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
phuelish
Contributor III
Contributor III

(yet another) set analysis with a variable question

Hi all,

I've looked through about a dozen posts on the forum to try to solve this, but can't seem to figure out the correct syntax. I'm trying to use a variable as a criteria in a set expression. The variable returns a string concatenation based on the selections made in two combo-boxes.

chr(39)&

if(match(pMetric,'Frq-P','Sev-P','Frq-R','PP-P')>0,only(Cov_Prefix),'')&

only(Num_1)&chr(39)


When expanded as =$(vNumFilter), this returns the following string: 'PD_Paid_$', which is correct based on the selections I've made. I'm running into problems when I try to use it in a set expression. I've tried a variety of approaches and can't seem to get it to work:


Sum({<Metric={"=$(vNumFilter)"}>}Result)

Sum({<Metric={"$(vNumFilter)"}>}Result)

Sum({<Metric={=$(vNumFilter)}>}Result)

Sum({<Metric={$(vNumFilter)}>}Result)

Sum({<Metric={$(=vNumFilter)}>}Result)

I've also tried the variable with and without the chr(39) for the single quotes. I've also tried substituting the text string directly just to make sure it's not the variable. the equation works correctly in this format:


Sum({<Metric={'PD_Paid_$'}>}Result)

What am I missing or doing wrong? Thanks for any help you can provide.

-Frank

1 Solution

Accepted Solutions
phuelish
Contributor III
Contributor III
Author

I figured out the problem. Essentially it's a double-expansion problem. I need the variable to expand the possible values using p(), then would need to expand the variable.

I managed to make it work by sticking the variable equation directly inside the set analysis and modified it slightly.

Sum({<Metric={$(=if(match(pMetric,'Frq-P','Sev-P','Frq-R','PP-P')>0,only(Cov_Prefix),'')&only(Num_1))}>}Result)

View solution in original post

6 Replies
sunny_talwar

How about this

Sum({<Metric={$(=$(vNumFilter))}>}Result)

or this

Sum({<Metric={$(vNumFilter)}>}Result)

phuelish
Contributor III
Contributor III
Author

Unfortunately, no

sunny_talwar

Did you remove the double quotes?

phuelish
Contributor III
Contributor III
Author

I did

sunny_talwar

Would it be possible to share a sample to check this out?

phuelish
Contributor III
Contributor III
Author

I figured out the problem. Essentially it's a double-expansion problem. I need the variable to expand the possible values using p(), then would need to expand the variable.

I managed to make it work by sticking the variable equation directly inside the set analysis and modified it slightly.

Sum({<Metric={$(=if(match(pMetric,'Frq-P','Sev-P','Frq-R','PP-P')>0,only(Cov_Prefix),'')&only(Num_1))}>}Result)