Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ksomosera10
Creator II
Creator II

Qlik Sense SaaS Dimension, Variable & If-Else

Hi Experts,


I'm working on a KPI but the problem is that I wanted to be flexible that the user can click on a selection and the dimension of all the charts will be replaced by the dimensions corresponding to the user's selection.

I'm using a 'Variable Input' object to store the selection of the user into a Variable.

Then, the variable will be my condition in an if-else statement inside the Dimensions Fx.

Here's a sample of that expression:

=If(vDimensionSelection = 'Books',  BookNames,
if(vDimensionSelection = 'Cars', CarBrands,
if(vDimensionSelection = 'Fruits', FruitNames,
if(vDimensionSelection = 'Country', CountryNames))))

Thank you in advance!

10 Replies
vinieme12
Champion III
Champion III

use Pick & WildMatch instead

=Pick(WildMatch(vDimensionSelection , 'Books',  'Cars', 'Fruits', 'Country'),BookNames,CarBrands,FruitNames,CountryNames)

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

Hi vinieme12,

 

I've tried using Pick & WildMatch but the result is still blank.

I don't know why it cannot read the fieldnames based on the variable selected on the dimension.


Thanks.

vinieme12
Champion III
Champion III

let me understand this

vDimensionSelection  = getfieldselections(DimensionName)

vSelectedDimension 

=Pick(WildMatch('$(vDimensionSelection)', 'Books',  'Cars', 'Fruits', 'Country'),BookNames,CarBrands,FruitNames,CountryNames)

 

in chart Dimension =

$(vSelectedDimension )

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

Hi Vinieme,

 

Does this line accepts multiple dimensions?

vDimensionSelection  = getfieldselections(DimensionName)

My issue that the user can select a value from a "Variable Input" and based on the value,

The dimension of the chart will change...

If I will translate your Pick&Match to what I need it'll be like this:

=Pick(WildMatch('$(vDimensionSelection)', 'Variable Input 1',  'Variable Input 2', 'Variable Input 3', 'Variable Input 4'),Dimension 1,Dimension 2,Dimension 3,Dimension 3)

But I've tried this approach and didn't worked. ;(

 

Vegar
MVP
MVP

I believe you are almost there. Try using this pick-match.

vSelectedDimension= Pick(Match('$(vDimensionSelection)', 'Books',  'Cars', 'Fruits', 'Country'), 'BookNames','CarBrands', 'FruitNames', 'CountryNames')

And then this dimension expression:

[$(vSelectedDimension)]

vinieme12
Champion III
Champion III

I'd also suggest you go thru this blog

 

https://community.qlik.com/t5/Qlik-Design-Blog/Customizable-Straight-Table/ba-p/1464825

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

For you this should like below

=Pick(WildMatch('$(vDimensionSelection)'

, chr(39)&variable1&chr(39)

, chr(39)&variable2&chr(39)

, chr(39)&variable3&chr(39)

, chr(39)&variable4&chr(39)

),Dimension1,Dimension2,Dimension3,Dimension4)

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

Hi Experts,

I think I understand how you wanted it to be executed.

I'm almost there. However, what I don't understand is how I will put that into translation.

I'm using a "Variable Input" object and as you can see in the image below, I'm capturing the value selected by the user to a variable vDimensionSelection.

ksomosera10_0-1639375178886.png

I think this is where I'm having trouble.

 

vinieme12
Champion III
Champion III

This is even simpler

You don't need any intermediate variables

Just use the Value~Label notations

 

Use below as dynamic value

'BookName~Books|CarBrand~Cars|FruitNames~Fruits|CountryName~Country'

 

in chart just use  $(vDimensionSelection)

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