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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Indirect Filter using RELATED Table

I am new to Power BI and hoping someone can help understand the reasoning and the correct way to do this. 

The sample PBIX file is available here:  https://ufile.io/iw27ae44 
1. The measure M1 is the original measure which works fine (responds to filter) when I use a filter through a slicer which uses a related table. 

2. The measure M2 FAIL is a scenario, where I am trying to do a mathematical operation (Example: 1 - CALCULATE RESULT = some %) on the result of the CALCULATE function. The measure yeilds correct results, but the data filter stops working. 

3. To make it work, I had a create a measure M2 PASS using column M2 Value with a hard coded, so that the CALCULATE doesn't loose context. It correctly corresponds to the date slicer. 

andy_pat_0-1596164785658.png

 


My questions are: 
1. Why does it loose context when I add a + or - operator. It seems to work with a * operator.
2. How I can achieve the M2 PASS result in an elegant / recommended way.

Thanks in Advance

Andy!

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@Anonymous 

Becasue your Dates table is joined to your Data table you don't need to use RELATED in your measure, M1 can just be 

 

M1 = SUM(Data[Sales])

 

Now, for the context on M2, it's not losing it it's just the fact that each date exists so it is able to calculate the 1 on every row.  If you only want to show it on rows where M1 is not blank you can do it like so.

 

M2 = 
VAR _M1 = [M1]
RETURN 
    IF ( NOT ISBLANK ( _M1 ), _M1 - 1, BLANK())

jdbuchanan71_0-1596166173445.png

 

 

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

@Anonymous 

Becasue your Dates table is joined to your Data table you don't need to use RELATED in your measure, M1 can just be 

 

M1 = SUM(Data[Sales])

 

Now, for the context on M2, it's not losing it it's just the fact that each date exists so it is able to calculate the 1 on every row.  If you only want to show it on rows where M1 is not blank you can do it like so.

 

M2 = 
VAR _M1 = [M1]
RETURN 
    IF ( NOT ISBLANK ( _M1 ), _M1 - 1, BLANK())

jdbuchanan71_0-1596166173445.png

 

 

Another way to do it is to use a trick of DIVIDE returning a BLANK on error and BLANK * <anything> is BLANK.

M2 V2 = 
VAR _M1 = [M1]
RETURN 
    DIVIDE( _M1 , _M1 ) * ( _M1 - 1 )

We use [M1] 3 times but because we used a VAR it only gets pulled by the DAX engine once. 

jdbuchanan71_0-1596166428163.png

 

amitchandak
Super User
Super User

@Anonymous , addition can force a left join. to avoid that try like

M2 FAIL = sumx(Data,
 1-SUM(Data[Sales])
 )
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

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.