Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
YT1916
Contributor II
Contributor II

How to use if statement in dimension expression and return a list of values?

Hi,

I want to create an expression for a dimension field to show different group of values within the dimension based on the field selections.

Below is the current expression I have to return only one value and it works properly. 

=If(GetFieldSelections(Trade) = 'A', 'A-1', Relation)

However, when I want to return 2 values, seems like the list of values does not work within the if statement.

=If(GetFieldSelections(Trade) = 'A', ['A-1' , 'A-2'], Relation)

 

Could anyone please help in this case? Much appreciate!

11 Replies
shahzaib332
Contributor
Contributor

Certainly! It looks like you're trying to handle multiple values within the IF statement. In QlikView or Qlik Sense, you can use the Match() function to achieve this. Here's an example:

https://ehsaasprograam.com/

=If(Match(GetFieldSelections(Trade), 'A') > 0,
if(Match(Relation, 'A-1', 'A-2') > 0, Relation)
)

 

This expression checks if the selected value in the 'Trade' field is 'A', and if the 'Relation' field matches either 'A-1' or 'A-2'. Adjust it based on your specific requirements and the structure of your data.

vinieme12
Champion III
Champion III

if you can define the relations logically you should be able to associate them in the data model level

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.