Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
DanCasSan
Helper V
Helper V

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!

 

bar_comparison.jpg

1 ACCEPTED SOLUTION

@DanCasSan 

 

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:

result.JPG

 

Attached is the PBIX file:

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
MFelix
Super User
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.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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]))

 

Capture1op.JPGCapture2op.JPG

Hi @DanCasSan ,

 

I did a measure similar to yours (with measures and SUMS) and worked correctly.

 

Are you abble to share a mockupfile?


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@DanCasSan 

 

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:

result.JPG

 

Attached is the PBIX file:

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






u are a bonnet! 

amitchandak
Super User
Super User

Check, if this can help

https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...

 

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

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.