Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

charleslitten
New Contributor

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
erik_wetterberg
Honored Contributor

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

Hi,

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

Erik Wetterberg

Erik Wetterberg
https://extendingqlik.upper88.com/
charleslitten
New Contributor

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

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
New Contributor III

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

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
New Contributor III

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

Hi,

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

karthiksrqv
Contributor II

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

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.

Community Browser