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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
SuraMan
Advocate II
Advocate II

Evaluation context inside FILTER

Hello,

 

I have a question about how evaluation takes place in the code snippet below. This filter() returns all the dates in 'Date'[Date] which are equal or less than the highest date in the current filter context.

 

FILTER ( 
ALL ( ‘Date’[Date] ),
‘Date’[Date] <= MAX( ‘Date’[Date] )
)

 

My question is, since ALL() removes any filters on 'Date'[Date] above, why does MAX(‘Date’[Date])  not return the last date in the full table 'Date'[Date], ignoring the current filter context?

For the above code to work as intended, MAX( ‘Date’[Date] ) has to be evaluated in the original filter context disregarding the effects of ALL(), however, it is not clear to me what rules determine that MAX() has to be evaluated in that manner.

If we look at the third line; it looks like ‘Date’[Date] evaluates in ALL() context while MAX(‘Date’[Date]) evaluates in the original context. Two different evaluation contexts for the two references of ‘Date’[Date] in the same line!

If you can clarify this, that would be wonderful.

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@SuraMan 

 

I believe the rule to remember is that
Inside a MEASURE

1) Expressions like SUM,MAX will always respond to available FILTER CONTEXT
Since FILTER is only an iterator and introduces ROW CONTEXT only,    MAX( ‘Date’[Date] ) responds to the FILTER context of the VISUAL (Matrix, Table, chart etc) which you are using.
If you use CALCULATE(MAX( ‘Date’[Date] )), we should get different results because in that case it will transform the ROW CONTEXT introduced by FILTER function into FILTER CONTEXT.
2) Naked column references (TableName[ColumnName]) inside an INTERATOR like FILTER,SUMX,MAXX will refer to ROW CONTEXT of that ITERATOR

 

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@SuraMan 

 

I believe the rule to remember is that
Inside a MEASURE

1) Expressions like SUM,MAX will always respond to available FILTER CONTEXT
Since FILTER is only an iterator and introduces ROW CONTEXT only,    MAX( ‘Date’[Date] ) responds to the FILTER context of the VISUAL (Matrix, Table, chart etc) which you are using.
If you use CALCULATE(MAX( ‘Date’[Date] )), we should get different results because in that case it will transform the ROW CONTEXT introduced by FILTER function into FILTER CONTEXT.
2) Naked column references (TableName[ColumnName]) inside an INTERATOR like FILTER,SUMX,MAXX will refer to ROW CONTEXT of that ITERATOR

 

Thanks @Zubair_Muhammad  for the explanation

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.