I would like to create a line chart where the user can select which metric he would like to see displayed.
For instance, there are three different measures: A, B and C. The idea is to add a dropdown list where the user can select which metric he would like to see displayed. More than 1 metric can be displayed on the chart.
Is this possible to achieve on Quicksight? I already was able to do it using a Parameter and a respective control. Although I am only allowed to choose one metric at time, and I would like to be able to select more than one.
Hi @MiguelA and welcome to the QuickSight community!
Yes, this is possible to achieve. When you’re setting up your parameter (unfortunately once created, this option can not be modified so you’ll have to re-create the one you’ve already done), you’ll want to choose ‘Multiple Values’ instead of ‘Single Value’. Then under static default value, put ALL_VALUES so that it populates all as default.
Hi @Brett ! Thank you so much for the quick reply and for the welcoming!
I created the parameter as you suggested. I can now select multiple values, although if I select more than one option, only one line will appear on the Line Chart. The idea is to display as many lines as the ones selected on the Metric Selector.
Hi @MiguelA,
Are we dealing with 3 different fields here (one each for A, B & C)?
If they’re all feeding from the same field, it may have something to do with your expression above. For your ‘in’ statements, you would need an actual field to check that against. Also, if you’d like to check for select all you’ll need to add ‘in(NULL, ${MetricSelector3})’
Overall, it may look like this: ifelse(in({field}, ${MetricSelector3}) OR in(NULL, ${MetricSelector3}), {field}, NULL)
Essencially A, B and C correspond to three different columns in my dataset. On the expression that you sent, where I should input the string that will be selected on the control by the user? (‘A’, ‘B’ and ‘C’)
I tried this Expression, and the issue still persisted
ifelse(
in('A', ${MetricSelector3}) OR in(NULL, ${MetricSelector3}), avg(A),
in('B', ${MetricSelector3}) OR in(NULL, ${MetricSelector3}), avg({B}),
in('C', ${MetricSelector3}) OR in(NULL, ${MetricSelector3}), avg(C),
NULL)
Do you have any idea of how I can sort this? I would be very appreciated Brett! Thank you so much so far for all the support given!!
After creating parameter with default value: ALL_VALUES and adding control. you need to write three different calculated fields for each A, B and C. like this:
ifelse(
in(‘A’, ${MetricSelector3}) OR in(NULL, ${MetricSelector3}),
A , NULL