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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
OrthoData
Frequent Visitor

Help with Filters and Slicers

All,

 

I currently have a measure Total Orders:= DISTINCTCOUNT( 'Orders'[Order ID]) that gives me the total number of orders in the fact table below. I have a slicer built off field marked 1. in the screenshot which has a number of categories. This successfully filters all visuals on a page using the Total Orders measure. 

Data Model.png

My issue is that some of the categories from that slicer have only specific Payors applicable and should be filtered out when selected. These payors are grouped in the calculated column marked 2. I tried modifying my measure to include this criteria using

 

Total Orders Modified:=
SWITCH(
    TRUE(),
    SELECTEDVALUE( 'Order Group'[Order Group] ) = "Category A", CALCULATE( DISTINCTCOUNT( 'Orders'[Order ID] ), AND( 'Payor'[Payor Groups] = "X", 'Payor'[Payor Groups] = "Y" ) ),
    SELECTEDVALUE( 'Order Group'[Order Group] ) = "Category B", CALCULATE( DISTINCTCOUNT( 'Orders'[Order ID] ), 'Payor'[Payor Groups] = "Z",
    DISTINCTCOUNT( 'Orders'[Order ID]
)

 

The modified measure works most of the time, but when placed against a set of items, instead of giving the breakdown total for each item, it gives the same amount for each. It's as though there's no relationship even though I have the relationships set up. What am I overlooking?

 

Thank you in advance for your time. 

 

1 ACCEPTED SOLUTION

@amitchandak , Kudos and thank you for your reply. I tried this version but it still caused the unwanted sum of the entire column regardless of the categories. 

 

In working through this, however, I did realize that the filter I wanted to apply when a slicer value was selected would not flow back up the chain to the dimension table. Therefore, I was able to rectify this by bringing the grouped Categories into the Fact table instead. The resulting code I used simply referenced the category column in the fact table, thus filtering the results.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

Try like

SWITCH(
    TRUE(),
    _max = "Category A", CALCULATE( DISTINCTCOUNT( 'Orders'[Order ID] ), 'Payor'[Payor Groups] in{ "X", "Y" } ),
    _max = "Category B", CALCULATE( DISTINCTCOUNT( 'Orders'[Order ID] ), 'Payor'[Payor Groups] = "Z"),
    DISTINCTCOUNT( 'Orders'[Order ID])
)
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak , Kudos and thank you for your reply. I tried this version but it still caused the unwanted sum of the entire column regardless of the categories. 

 

In working through this, however, I did realize that the filter I wanted to apply when a slicer value was selected would not flow back up the chain to the dimension table. Therefore, I was able to rectify this by bringing the grouped Categories into the Fact table instead. The resulting code I used simply referenced the category column in the fact table, thus filtering the results.

@OrthoData ,

If you can post the correct fomrula, that will help other users.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

Really difficult to tell without some sample data to test with. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler , Kudos and thank you for the tip! I will definitely streamline my future questions based on this article.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.