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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pceglie
Resolver I
Resolver I

Filter by a measure

Hi folks, I have one table with 2 measures

"Total Revenues" , "Total Budget"

I have a 3rd measure that prints "OK" if the first 2 columns have the same value otherwise prints "KO" if Total Revenues" <> "Total Budget". 

Works fine, but I can't insert a Slicer Filter to filter only rows with "OK" (or "KO") values

Any suggestion is appreciated.

Thanks,

1 ACCEPTED SOLUTION

@pceglie

 

We can't directly put a measure into a slicer since the measure need to be sliced to get the corresponding data. In your scenario, you can create a calculated table and build those measures into calculated column, then you can use apply slicers on these columns.

 

Calculated Table = ADDCOLUMNS(
Table,
"Purchased",CALCULATE(SUM('Fact Purchase'[Ordered Quantity])),
"Sales",CALCULATE(SUM('Fact Sale'[Quantity])),
"_meas", IF([Purchased]=[Sales];"OK";"KO")
)

Regards,

 

Simon Hou

View solution in original post

9 REPLIES 9

You can't put a measure as a slicer choice. You could try adding a bar chart with the 2 text items on the axis and count as the value. Then try clicking the bars



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi, thanks for your reply

"You could try adding a bar chart with the 2 text items on the axis and count as the value. Then try clicking the bars"

What do you mean with "with the 2 text items on the axis"?

I'm not able to add the 3rd measure as AXIS in a bar chart

Could you supply some sample data (as text, not screen shot) and your measure calculations so that the problem can be recreated? See this post:

http://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

For testing I use sample database WorldWideImportersDW

uno.PNG

and below my measures

Purchased = CALCULATE(SUM('Fact Purchase'[Ordered Quantity]))
Sales = CALCULATE(SUM('Fact Sale'[Quantity]))
_meas = IF([Purchased]=[Sales];"OK";"KO")

So I need filtering only rows "OK" or "KO"

Can you just use a Visual Filter, Page Filter or Report Filter?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I need a Visual Filter

@pceglie

 

We can't directly put a measure into a slicer since the measure need to be sliced to get the corresponding data. In your scenario, you can create a calculated table and build those measures into calculated column, then you can use apply slicers on these columns.

 

Calculated Table = ADDCOLUMNS(
Table,
"Purchased",CALCULATE(SUM('Fact Purchase'[Ordered Quantity])),
"Sales",CALCULATE(SUM('Fact Sale'[Quantity])),
"_meas", IF([Purchased]=[Sales];"OK";"KO")
)

Regards,

 

Simon Hou

How do you build this table? Where do you write the script you supplied?

 

Is there any documentation you can supply to show how this is done?

 

Thanks,

Dan.

I may be incorrect, but I'm not sure that is possible. The reason is that since it is a measure, it has a value in a visual only according to the specific context of that visual. Filters are special in that they allow measures to be used to filter visuals versus all of the visuals aren't going to allow you to do this in the way you want. There may be a tricky way around it but I'm not thinking of it right now. I seem to remember that perhaps there was a way around this or a similar problem by using VALUES...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.