Qlik Community

Qlik Sense App Development

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

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

Re: Calculated Dimension with if Condition Qliksense

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

4 Replies
luismadriz
Valued Contributor

Re: Calculated Dimension with if Condition Qliksense

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
Valued Contributor

Re: Calculated Dimension with if Condition Qliksense

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
Contributor II

Re: Calculated Dimension with if Condition Qliksense

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

Re: Calculated Dimension with if Condition Qliksense

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