Forum Discussion
Use measure as filter
Hello community!
Could someone guide me a little with this case? I am working on a measure as a filter to show a bar comparison, but what happens if I choose more than one option in the filter? I understand that the result could not be in a single measure, since if I choose more than one option, each option should be shown as a bar.
Any suggestions or tricks to do more or less what is on the chart? Whereas each option is a bar and you can select 1, 2, 3 or the 4 options.
Thank you so much!
Following MFelix idea of a measure table, if you need multiple selection, you can create a measure for each calculation along the lines of (This example is with my measures):
Sales 2018 (sel) = VAR calc = CALCULATE(DISTINCTCOUNT('Select Measure'[Selected Measure]); FILTER('Select Measure'; 'Select Measure'[Selected Measure]= "Sales 2018")) RETURN IF(ISBLANK([Countrows Select Measure]); BLANK() ; IF(calc= 1; [Sales 2018]; BLANK()))Which gets you this:
Attached is the PBIX file:
6 Replies
- amitchandak
Super User
Check, if this can help
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin - MFelix
Super User
Hi DanCasSan ,
Create a new table with the name of the measures you need you can add an ID to simplify and order also your data something similar to this
ID Measure 1 Measure 1 2 Measure 2 3 Measure 3 4 Measure 4 Then add the following measure to your model:
Selection measure = SWITCH( SELECTEDVALUE('Table'[Measure]); 1 ;[Measure 1]; 2;[Measure 2]; 3;[Measure 3]; 4;[Measure 4])Now add the column with the name measures on the legend or axis of your visualization, then place the previous measure on the values.
Create a slicer with the name measure from the table that you created and should work as expected.
Check a PBIX file with an example with 2 measures.
As you can see on the file the visualizations have different levels of information but all show or hide the selectted measures.
- DanCasSan
Helper V
Hi Miguel, I did what you recommended, but when I select more than one option, no information comes out. I enclose the image for more detail.
Measure =
SWITCH(
SELECTEDVALUE(DS_KPI_Unid[ID]),
1,[Consumo Real Und.],
2,[Ingreso Real Und.],
3,SUM(DS_MPSMRP[BDMNG]),
4,SUM(DS_MPSMRP[GSMNG]))- PaulDBrown
Community Champion
Following MFelix idea of a measure table, if you need multiple selection, you can create a measure for each calculation along the lines of (This example is with my measures):
Sales 2018 (sel) = VAR calc = CALCULATE(DISTINCTCOUNT('Select Measure'[Selected Measure]); FILTER('Select Measure'; 'Select Measure'[Selected Measure]= "Sales 2018")) RETURN IF(ISBLANK([Countrows Select Measure]); BLANK() ; IF(calc= 1; [Sales 2018]; BLANK()))Which gets you this:
Attached is the PBIX file: