Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
q11hhg
Contributor III
Contributor III

Use buttons to change the measures in bar chart

Hi there,

I would like to use buttons as filters to filter my bar chart.

For example, when I select the button 'Events', the bar chart will show me the Events by year month.

So I guess the button should be able to change the measure of the bar chart dynamically based on the selection.

I am not able to use any extensions. so this has to be done by writing expressions and setting up the button.

Could you please help?

q11hhg_0-1615385582119.png

 

Labels (1)
1 Solution

Accepted Solutions
q11hhg
Contributor III
Contributor III
Author

5 Replies
Or
Master III
Master III

Rather than using a button, consider using a field (filter pane). Either way, set up a variable (mine is called vFieldSelection) which sets up a formula attached to the value or button, for example:

if(myField = 'Sales', 'Sum(Sales)', 'Sum(Quantity)')

This would have a list of your measures. You would then create a measure:

=['$(vFieldSelection)']

If you prefer to use a button you'd just need to use the button to set the variable values, but the same concept will apply.

satish3922
Contributor II
Contributor II

Hello Pal,

to achieve you requirement we need to just follow below steps:

i am assuming Dimension  as YearMonth field

-> create a variable vSwitch assign value 'event'

satish3922_1-1615408890547.png

 

-> In your created button add action to set value in variable

  • select variable name as vSwitch
  • for event button put value as 'event' and for new buyer button put value as 'new buyer'

-> create two measure in bar chart

  • measure 1 : count(events)
  • measure 2 : count(New Buyer)

Now in measure both the measure go the calculation condition

satish3922_0-1615408828750.png

In event measure  calc. condition , put $(vSwitch)='event'

In new buyer measure calc. condition, put $(vSwitch)='new buyer'

 

done!

you are good to go.

 

q11hhg
Contributor III
Contributor III
Author

Hi @satish3922 

Thanks for your help, but I don't understand this 

-> create two measure in the bar chart

  • measure 1 : count(events) 
  • measure 2 : count(New Buyer)

--- I do not have a field called event or new buyer, they are the name of my measures. 

q11hhg
Contributor III
Contributor III
Author

satish3922
Contributor II
Contributor II

Hi @q11hhg 

you can use your show condition in your measure that is already created.

and use variable button to switch between them.

Please let me  know if you need a sample qliksense file with example.