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
AndreVar67
Frequent Visitor

DAX Measures: CALCULATE+REMOVEFILTERS vs SUMX +ALL+FILTER

Hi Community.

I search in this forum and in network also discussions about REMOVEFILTERS vs ALL.

Usage is not clear for me again...

 

I created a measure to calculate rolling (3,6,12 months depending by user choice ) but I got different result using REMOVEFILTERS and ALL+FILTER.

 

1st measure:

By my knowledge, I can use REMOVEFILTERS to delete specific filter in a table to apply new one and preserve any other filters:

 
(consider Country XX selected in the report)
....
CALCULATE ( sum(MyTable[#Volume] )
   ;REMOVEFILTERS( MyTable[ColumnDate] )
   ;and( MyTable[ColumnDate] >=VarFirstDate ;MyTable[ColumnDate] <=VarLastDate )
)
 
VarFirstDate,VarLastDate are calculated variables. Country filter continues to be applied.
 
2nd measure created due to incorrect result in previous. ALL function should remove all filters. 
 
Considering same Country XX selected in the report.
I calc VarFirstDate,VarLastDate and new variable VarSelectedCountry:
....
SUMX( filter( all(MyTable)
                  ;and(MyTable[CountryColumn] = VarSelectedCountry
                          ;and(MyTable[ColumnDate] >=VarFirstDate ;MyTable[ColumnDate] <=VarLastDate )
                     )
               )
      ;MyTable[#Volume]
)
 
This measure returns correct values.
Problem is that I need to evaluate any filter I have in the page (a lot of) and I need to change the measures (a lot of...) if I add a new filter in the page.
 
My opinion is I should have same results (of course, if above measures don't have errors...).
Thanks,
Bye!
 
 
 
 
 
1 REPLY 1
AndreVar67
Frequent Visitor

I found a solution adding REMOVEFILTES for the column I need to calculate.

I don't have filters on the values. No idea why it works...

Bye!

....

CALCULATE ( sum(MyTable[#Volume] )
   ;REMOVEFILTERS( MyTable[#Volume] )
   ;REMOVEFILTERS( MyTable[ColumnDate] )
   ;and( MyTable[ColumnDate] >=VarFirstDate ;MyTable[ColumnDate] <=VarLastDate )
)

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.

Top Solution Authors