Quick switching of different measures in visual
This article describes, how to change the values shown in a chart with one click.
For example here you can simply switch between pieces and total prices.
How to do it?
First you need a table containing values corresponding to values show in slicer. You can import the table or create it using DAX and DATATABLE function.
- List of values in chart = DATATABLE(
"Values in chart"; STRING;
{
{"Pieces"};
{"Total price"}
}
)
Let´s create a slicer, that uses this table.
Now create a measure, "switchable" by item selected in slicer.
- Selected value =
SWITCH(
SELECTEDVALUE('List of values in chart'[Values in chart]);
"Pieces";SUM('Sales data'[Pieces]);
"Total price";SUM('Sales data'[Total price]))
Use this measure in visual.
Now the item selected in slicer is "recognized" by SELECTEDVALUE and, depending on its value, returns one of multiple calculations.