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
Jeanxyz
Post Prodigy
Post Prodigy

difference between removefilters(), all()

Hi,

I'm confused with the use of all() and removefilters(). I wonder if someone can give me an explanation about the two calendar filters: all() vs removefilters().

 

I have written two measures using different calendar filters, in the visual part, I have selected YearMonth in the column filter. In the page filter, I have selected year 2021. The date filters in the measures, page filter and column fields use the same calendar table.

 

I have put my question in the measure. The visual in attached on the bottom. Thanks for the help in advance.

 

Company Currency Amount Base_BS =
VAR BS =
FILTER(VALUES('Dim_Group GL Account'[Level 0]),'Dim_Group GL Account'[Level 0] = "BS" )
VAR DatesSelectionAndEarlier =
FILTER (
ALL ( 'Dim_Date'[Date] ),
'Dim_Date'[Date]
<= MAX ( 'Dim_Date'[Date] )
)
var CompCurrAmt = CALCULATE(sum('Fact_GL Entries'[Company Currency Amount]),BS,DatesSelectionAndEarlier)
//Question: it looks like the DatesSelectionAndEarlier overrides the YearMonth context in the column field. Is that how all() function works? i.e., all() will always removes all the filters in the calendar table even if the all() function only asks to remove filter in the [Date] field?
var result1 = if(HASONEVALUE('Dim_Legal Entity'[Legal Entity ID]),CompCurrAmt,BLANK())
var result2 = DIVIDE(result1,[SelectedUOM])
return
result2
 
Company Currency Amount Base_BS2 =
VAR BS =
FILTER(VALUES('Dim_Group GL Account'[Level 0]),'Dim_Group GL Account'[Level 0] = "BS" )
var CompCurrAmt = CALCULATE(sum('Fact_GL Entries'[Company Currency Amount]),BS,removefilters(Dim_Date[YearMonth]) )
//here by removefilters(), I expect the measure will override YearMonth filter in the column field. However, it looks the YearMonth value in the column field still has an impact. I only get the total results to Jan. instead of all months in 2021.
 
var result1 = if(HASONEVALUE('Dim_Legal Entity'[Legal Entity ID]),CompCurrAmt,BLANK())
var result2 = DIVIDE(result1,[SelectedUOM])
return
result2
 
 

 

 

filter context.PNG

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Jeanxyz 

Not clear about the measures you have used. If you need a good video the refer to this please: 
https://www.youtube.com/watch?v=O8S1XoRss28

Also this:
https://www.youtube.com/watch?v=O4co3WFMjfw


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
powerbi_zone
Frequent Visitor

Hello Dear ,

Its not as complicated as you may think 🙂

Differences between ALL() and REMOVEFILTERS()

REMOVEFILTERS is just an alias of ALL here, so it works in the same manner.

Basically, using only ALL() returns a table including all rows, ignoring any filters that might have been applied.

However, when ALL is used as a filter argument of CALCULATE / CALCULATETABLE, it behaves differently: it removes filters from the table and does not return a table.

To eliminate this confusing behavior of ALL, REMOVEFILTERS was introduced to replace ALL when it is used inside CALCULATE.

You can find more in this video.Hope it helps!

v-xiaotang
Community Support
Community Support

Hi @Jeanxyz 

Have you solved this problem? If yes, could you kindly accept the answer helpful as the solution (or kindly share your solution ). so the others can find it more quickly.

 

 

Best Regards,

Community Support Team _Tang

Fowmy
Super User
Super User

@Jeanxyz 

Not clear about the measures you have used. If you need a good video the refer to this please: 
https://www.youtube.com/watch?v=O8S1XoRss28

Also this:
https://www.youtube.com/watch?v=O4co3WFMjfw


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thanks a lot, Fowmy! As usual, you gave me good guidance.

 

I did a test with a small sales fact table as below and link it to dim_date table. I also created three measures using removefilters(), all(), var respectively. It turns out all() and removefilters() generate the same results, both remove the filter in [Date] column, but if there is filter applied to another column in the Dim_Date table, [Date] field is still filtered. E.g., if I filter year 2021, then only dates in year 2021 are included in measure 1 and measure 2 , dates in year 2020 are not considered.

 

The last measure however works quite differently, the var DatesSelectionAndEarlier actually ignores any filters related to dim_Date table and calculate dates from the very 1st day in the dim_date table till the last day in the dim_date table.

 

So the learning here is var functions work seperately from current filtering context and start from the whole table.

 

 

 

 

1. sales removefilters = calculate([sales],removefilters(Dim_Date[Date]))
2. sales all = calculate([sales],all(Dim_Date[Date]))
3. sales from day1 till maxdate =

VAR DatesSelectionAndEarlier =
FILTER (
All ( 'Dim_Date'[Date] ),
'Dim_Date'[Date]
<= MAX ( 'Dim_Date'[Date] )
)
var SalesAmt = CALCULATE([sales],DatesSelectionAndEarlier)
return
SalesAmt

 

 

test dataset.PNG

 

3 filters.PNG

Thanks,

So did it solve the problem and your query? 🙂


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.