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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
unknown_anony
Helper I
Helper I

Calculate YTD sum of previous month from the maximum month

Hello All,

I have a table which has the data till Sept which is the maximum month . i have a date column first of everymonth  in the Table.I want to have the YTD value till prevoius month of maximum month
How to calculate the sum? 

Thank you in advance
I got lot of support form you guys.

 

1 ACCEPTED SOLUTION
v-rongtiep-msft
Community Support
Community Support

Hi @unknown_anony ,

Please have a try.

YTD Sales = 
VAR MaxMonth = MAX(Orders[Order_Date].[MonthNo])
VAR PrevMonth = MaxMonth - 1
RETURN
TOTALYTD(SUM(Orders[Sales]), Orders[Order_Date], Orders[Order_Date].[MonthNo] <= PrevMonth)

 TOTALYTD function (DAX) - DAX | Microsoft Learn

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

3 REPLIES 3
v-rongtiep-msft
Community Support
Community Support

Hi @unknown_anony ,

Please have a try.

YTD Sales = 
VAR MaxMonth = MAX(Orders[Order_Date].[MonthNo])
VAR PrevMonth = MaxMonth - 1
RETURN
TOTALYTD(SUM(Orders[Sales]), Orders[Order_Date], Orders[Order_Date].[MonthNo] <= PrevMonth)

 TOTALYTD function (DAX) - DAX | Microsoft Learn

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

 

 

 

Ahmedx
Super User
Super User

Can you please share your demo input and expected output!

Thankn you @v-rongtiep-msft .
The above solution worked fine @Ahmedx . Thank you 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.