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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Mani_ms
Helper I
Helper I

Calculate total not matching with Max function

Hi ,

 

I have table by country and quantity with month category.

I am bringing YTD quantity based on Max Function if current month equal to Max and  i want to return until previous month YTD quantity.

By month i can able to get the desired result but in total its giving including the current month.

Mani_ms_0-1597840723299.png

In the above example August also included in the total. but month fileterd untill July correctly.

 

Thanks,

Mani

 

1 ACCEPTED SOLUTION

Hi @Mani_ms ,

 

Do you want to calculate the cumulative value when the month is equal to today's month, the other months show the value of the current month?

For example, when the month name is Aug, it will calculate the cumulative value.

 

Ca1.jpg

 

If yes, you can use the following measure.

 

Measure = 
var _YTD = CALCULATE(SUM('Table'[quantity]),FILTER(ALLEXCEPT('Table','Table'[Country]),'Table'[Month number]<=MAX('Table'[Month number])))
var _currentmonth = FORMAT(TODAY(),"mmm")
var _sum = SUM('Table'[quantity])
return
IF(
    MAX('Table'[Month name])=_currentmonth,_YTD,_sum)

 

Ca2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

View solution in original post

7 REPLIES 7
v-zhenbw-msft
Community Support
Community Support

Hi @Mani_ms ,

 

How about the result after you follow the suggestions mentioned in my original post?

Could you please provide more details or expected result about it If it doesn't meet your requirement?

If you've fixed the issue on your own please kindly share your solution. If the above posts help, please kindly mark it as a solution to help others find it more quickly.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

harshnathani
Community Champion
Community Champion

Hi @Mani_ms ,

 

You can remove VALUE from the formula.

 

https://dax.guide/value/

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

 

Hi @harshnathani ,

 

Value i have used to convert text to number for the period. Somewhere i am missing..

Hi @Mani_ms ,

 

Do you want to calculate the cumulative value when the month is equal to today's month, the other months show the value of the current month?

For example, when the month name is Aug, it will calculate the cumulative value.

 

Ca1.jpg

 

If yes, you can use the following measure.

 

Measure = 
var _YTD = CALCULATE(SUM('Table'[quantity]),FILTER(ALLEXCEPT('Table','Table'[Country]),'Table'[Month number]<=MAX('Table'[Month number])))
var _currentmonth = FORMAT(TODAY(),"mmm")
var _sum = SUM('Table'[quantity])
return
IF(
    MAX('Table'[Month name])=_currentmonth,_YTD,_sum)

 

Ca2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

amitchandak
Super User
Super User

@Mani_ms , Not very clear. You can use time intelligence, if you date with date calendar.

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))

 

 

Power BI — YTD
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

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

@amitchandak ,

Could you please help me out the YTD value prior period quantity based on current month.

Greg_Deckler
Community Champion
Community Champion

@Mani_ms - This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.