Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear All Qlik Guru's
I have a measure Sum({$<Year={2009}>,<Country={'Sweden'}>} Sales), i want to create a toggle button, like
when i click 'ON' in the button , -the expression should be Sum({$<Year={2009}>,<Country={'Sweden'}>} Sales)
When i click 'OFF' in the button, the expression should be Sum({$<Year={2009}>} Sales)
Could you please help me with the step by step process for this requirement, i am new to Qliksense, Kindly help me please..
Hello,
Here are the steps that I have followed to achieve a similar use case scenario:
1. The demo data:
2. No I have created a new variable with a default option 1:
3. After that I have created a new button and added an action:
4. Now I have created a Bar chart, added Year as dimension and as measure added: =If($(vSelected) = 1, Sum({<Year={2019}, Country={'Sweden'}>} Sales), Sum({<Country={'Sweden'}>} Sales))
This will evaluate different expression, based on selected value in the variable.
5. As option one I can see:
If clicked I can see:
As you can see, for option one the expression indicates that we only show the values for Year 2019 and Country Sweden and for expression 2, it will show all the values for Country Sweden for all years. The Bar chart reflects those selections as well.
NOTE: Your expression had some issues, so I used slightly modified version of it. First use the expression individually on the chart to ensure that the data is presented as you want them and then use them in the If() statement.
I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in details by providing additional information. However, if it has helped you resolve the issue, addressed your concerns or at least pointed you in the right direction, please mark it as Accepted Solution to give further visibility to other community members.
i propose an alternative. instead of using your variable as a criteria in the if statement, use it to contain your set analysis modifier:
if on
',<Country={'Sweden'}'
if off
''
then in your expression:
Sum({$<Year={2009}>$(variable)>} Sales)
the advantage is that there is no if statement evaluated for each row. be careful with the comma at the start of the value for when on
Hello,
Here are the steps that I have followed to achieve a similar use case scenario:
1. The demo data:
2. No I have created a new variable with a default option 1:
3. After that I have created a new button and added an action:
4. Now I have created a Bar chart, added Year as dimension and as measure added: =If($(vSelected) = 1, Sum({<Year={2019}, Country={'Sweden'}>} Sales), Sum({<Country={'Sweden'}>} Sales))
This will evaluate different expression, based on selected value in the variable.
5. As option one I can see:
If clicked I can see:
As you can see, for option one the expression indicates that we only show the values for Year 2019 and Country Sweden and for expression 2, it will show all the values for Country Sweden for all years. The Bar chart reflects those selections as well.
NOTE: Your expression had some issues, so I used slightly modified version of it. First use the expression individually on the chart to ensure that the data is presented as you want them and then use them in the If() statement.
I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in details by providing additional information. However, if it has helped you resolve the issue, addressed your concerns or at least pointed you in the right direction, please mark it as Accepted Solution to give further visibility to other community members.
i propose an alternative. instead of using your variable as a criteria in the if statement, use it to contain your set analysis modifier:
if on
',<Country={'Sweden'}'
if off
''
then in your expression:
Sum({$<Year={2009}>$(variable)>} Sales)
the advantage is that there is no if statement evaluated for each row. be careful with the comma at the start of the value for when on