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

Calculated Dimension with if Condition Qliksense

Hi all,

We are having a requirement where we have a filter with two options Yearly and  Monthly level in Qliksense.

Based on the selection, the Dimension in the charts should change to Year or Month.


We are using following expression for the Dimension

if(getfieldselections(Period) ='Yearly',[Year],[Month])


It works fine if you select Yearly or Monthly in Period filter but as soon as we filter using Dimension Year or Month

it behaves in a strange manner.It shows Dimension only at Monthly Level even if you have selected Yearly or Monthly  in Period filter

So it ignores the if condition and selects the else condition as shown below

if(getfieldselections(Period) ='Yearly',[Year],[Month])


We tried using Master items as dimension but it was giving same results

Needed help on this

Regards,

Bhargav

1 Solution

Accepted Solutions
calexandru
Partner - Contributor III
Partner - Contributor III

Hi Bhargav,

Might I suggest you try out the qsVariable extension over on Qlik Branch? It looks like it might be exactly what you are looking for.

You can create two buttons, Yearly and Monthly and based on the user's selection have the measure return different  calculations by way of an if statement. As an approach it's very similar to your implementation but it should be more fluid in terms of user interaction.

Cheers,

Alex

View solution in original post

4 Replies
luismadriz
Specialist
Specialist

Hi,

Create a little text box and display the results of getfieldselections(Period) and see if it changes as you make other selections


Cheers,


Luis


luismadriz
Specialist
Specialist

No that's not it.

Is Period in any way linked to other fields in your database?  I hope not, it should be an island table (not connected to anything) and not existing in a table with other fields

Luis

bhargav_bhat
Creator II
Creator II
Author

Hi Luis,

Thanks for Replying,

Period Field is not linked to any field and I have taken an inline load for it.But strange thing is when we filter a dimension Year or Month then both values in Period field i.e Quarterly and Monthly gets selected automatically even without association

I have attached a qvf file for reference

Thanks & Regards,

Bhargav

calexandru
Partner - Contributor III
Partner - Contributor III

Hi Bhargav,

Might I suggest you try out the qsVariable extension over on Qlik Branch? It looks like it might be exactly what you are looking for.

You can create two buttons, Yearly and Monthly and based on the user's selection have the measure return different  calculations by way of an if statement. As an approach it's very similar to your implementation but it should be more fluid in terms of user interaction.

Cheers,

Alex