Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

setting a variable with a listbox

Hello

I can't create a two-dimensional pivot table and have the expression in a cycle group. The cycle group button does not appear in the table.

So to get round this I'm using a variable to hold the the expression in the pivot table. For example, the variable contains the text "sum(payments)". This works fine, but now I need the user to be able to select from a list of available expressions, which will change the value of the variable and alter the table. What's the best way to do this?

Is there a better alternative to this idea? Hope this makes sense!

Thanks.

1 Solution

Accepted Solutions
tanelry
Partner - Creator II
Partner - Creator II

You can make a variable to list predefined values in drop-down (see input box properties).
Then make chart expression to perform different calculations based on selected variable
Chart expression: if(vMeasure='Sales',sum(Sales), if(vMeasure='Payments',sum(Payments), if .... )))

Another possibility is to load an inline table to show the measures in list box, instead of drop-down.

Measures:
LOAD * INLINE [
Measure
Sales
Payments
];

Chart expression: same as above.

And yet another possibility is to load inline table with both measure and expression, like:
Measures:
LOAD * INLINE [
Measure, ChartExpression
Sales, sum(Sales)
Payments, sum(Payments)
];

Chart expression: $(=ChartExpression)

View solution in original post

3 Replies
maneshkhottcpl
Partner - Creator III
Partner - Creator III

Hi,

If possible please send the sample application. I will help u.

tanelry
Partner - Creator II
Partner - Creator II

You can make a variable to list predefined values in drop-down (see input box properties).
Then make chart expression to perform different calculations based on selected variable
Chart expression: if(vMeasure='Sales',sum(Sales), if(vMeasure='Payments',sum(Payments), if .... )))

Another possibility is to load an inline table to show the measures in list box, instead of drop-down.

Measures:
LOAD * INLINE [
Measure
Sales
Payments
];

Chart expression: same as above.

And yet another possibility is to load inline table with both measure and expression, like:
Measures:
LOAD * INLINE [
Measure, ChartExpression
Sales, sum(Sales)
Payments, sum(Payments)
];

Chart expression: $(=ChartExpression)

chris_johnson
Creator III
Creator III

Hi there,

I know this one has been solved a while ago but it helped me in doing something and thought I'd add something on the end of this post for anyone else.

I found that putting the expressions in the inline table works but you have to be careful referring to fields which have multiple words in them. For example, I tried to put an expression (along with a load of set analysis, which worked!) into the inline table but it seemed to be giving me trouble as it was in there as [Invoice Value]. I changed this to say "Invoice Value" instead and it worked.

Just thought I'd add that little nugget.

Chris