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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Applicable88
Impactful Individual
Impactful Individual

Question regarding syntac/ context transition cumulative sum

Hello,

I have a misunderstanding regarding the max within a cumulative sum/range sum:

RangeSum = [SumOfTotalAmount] -calculate(sum(Table1[Amount]), filter(allselected(Table1), Table1[Date].[Date] <= max(Tabl1[Date])))
 
First of all the function works properly, but regarding the last filter par:
Table1[Date].[Date] <= max(Table1[Date])))
Shouldn'T the max ()-function return the max date of all available rows of the whole table? Instead it rightfully display all the dates smaller or equal of the Date we look at, on that specific row. Since its a scalar function an there is no wrapping inside a Calculate function like calculate(max(Table1[Date])), how is a row context establish here? 
Also no X-aggregated function where use, so how it will no the row context?
 
I'm also asking because there might be some demands on other calculation where you want to compare to the MAX of something. That might be not the date. In that case you want it to compare to the MAX of the whole column. In this case how would I need to write it differently?
 
I hope I explained clear of what is my misunderstanding. 
Thank you very much in advanced.
Best regards. 
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Applicable88 , max(Table1[Date])  will take the row context , if need overall max try 

var _max = maxx(allselected(Table1), Table[Date]) // max of allselected

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

View solution in original post

v-angzheng-msft
Community Support
Community Support

Hi, @Applicable88 

 

I have an easy to understand explanation here, although it may not be completely correct. Glad to see different insights.
Max/Min/Sum functions are based on the row context, each row is a filtering condition, in the current row whether the maximum or minimum result is the current row, because the context is only one row?
So it will be seen in the column whether the Max function or Min function, the result is the value of the current row.
In the total, the context of the row is the whole table or rather all rows, so the result is correct in the total.
If you want to remove the limitation of the context, then you need to remove the filtering effect of the row context i.e. remove the filtering. 

vangzhengmsft_0-1626080708567.png

Then the DAX that correctly takes the maximum value could look like the following:

_realMaxDate = CALCULATE(MAX('Table'[Date]),ALL('Table'))

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-angzheng-msft
Community Support
Community Support

Hi, @Applicable88 

 

I have an easy to understand explanation here, although it may not be completely correct. Glad to see different insights.
Max/Min/Sum functions are based on the row context, each row is a filtering condition, in the current row whether the maximum or minimum result is the current row, because the context is only one row?
So it will be seen in the column whether the Max function or Min function, the result is the value of the current row.
In the total, the context of the row is the whole table or rather all rows, so the result is correct in the total.
If you want to remove the limitation of the context, then you need to remove the filtering effect of the row context i.e. remove the filtering. 

vangzhengmsft_0-1626080708567.png

Then the DAX that correctly takes the maximum value could look like the following:

_realMaxDate = CALCULATE(MAX('Table'[Date]),ALL('Table'))

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Applicable88 , max(Table1[Date])  will take the row context , if need overall max try 

var _max = maxx(allselected(Table1), Table[Date]) // max of allselected

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors