5 Replies Latest reply: Aug 25, 2018 10:02 AM by Karthik Srinivasan

# 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.

• ###### 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

• ###### 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

• ###### 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.

• ###### 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?

• ###### 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.