cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors