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: 
Anonymous
Not applicable

How to use a valuelist as a result of an if statement

I'm trying to make a table that is dynamic based on a selection

So if 'x' is selected I want the dimension in the table to be x1, x2 and x3 which have their own values in the table.

but if 'y' is selected the dimension are different y1, y2, y3.

I'm trying to use an if statement and the GetFieldSelections function for the dimension

IF(GetFieldSelections(Type)='x', valuelist('x1', 'x2' , 'x3'), IF(GetFieldSelections(Type)='y', valuelist('y1' 'y2', 'y3')), Z)

However the formula only returns 'x' or 'y' depending on what is selected.

5 Replies
ErikWetterberg

Hi,

Have you tried with a Valuelist with if's inside it?

Erik Wetterberg

Anonymous
Not applicable
Author

Yes and that works but I was hoping to simplify it. Otherwise when I use it to calculate the values of the table the amount of text will grow exponentially.

There are 40 different fields in the dimension. 20 for x and 20 for y

graham-crooks
Contributor III
Contributor III

Hi Charles,

Interesting that you say Eriks suggestion works. I coded something similar into a dimension and all was well until I saved the App. Now it tells me I have an invalid dimension and that "All parameters to ValueList must be constant", which of course they're not since trying to make them dynamic was the point in the first place! Uughh.

wenkew186
Creator
Creator

Hi,

maybe you can use 2 calculate dimensions and make the if condition to condition show?

karthiksrqv
Partner - Creator II
Partner - Creator II

Hi,

Please try to construct the value list in a variable. The resulting value of the variable should be just the valuelist. This variable can then become your dimension. This could make it dynamic.