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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.