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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply

How to calculate previous year to date ends with previous year current month

Hi Guys,

I have measure that calculate total units, i want to calculate previous year to date ends with previous year current month.
Today date - 10/4/2024
Logic is
PYTD = Jan-2023 to Sep-2023 ( because completed month in current year )

1 ACCEPTED SOLUTION
Kedar_Pande
Community Champion
Community Champion

@newlearnpbi123 

DAX measure:

PYTD_TotalUnits = 
CALCULATE(
[Total Units], -- Your total units measure
DATESBETWEEN(
'Date'[Date],
DATE(YEAR(TODAY()) - 1, 1, 1), -- Start from January 1 of the previous year
EOMONTH(DATE(YEAR(TODAY()) - 1, MONTH(TODAY()) - 1, 1), 0) -- End at the last day of the previous year's current month
)
)


This will calculate the total units for Jan 2023 to Sep 2023 (PYTD).

 

If this helped, a Kudos 👍 or Solution mark would be great!
Cheers,
Kedar Pande
www.linkedin.com/in/kedar-pande

If this helped, please give Kudos or mark it as a Solution .
Best regards,
Kedar
Connect on LinkedIn

View solution in original post

4 REPLIES 4

thank you so much, it is working,
is there any way i could use a column where there is a month id like "M001","M002","M003"
i could use the month id column in the end of month like filter.

Kedar_Pande
Community Champion
Community Champion

@newlearnpbi123 

DAX measure:

PYTD_TotalUnits = 
CALCULATE(
[Total Units], -- Your total units measure
DATESBETWEEN(
'Date'[Date],
DATE(YEAR(TODAY()) - 1, 1, 1), -- Start from January 1 of the previous year
EOMONTH(DATE(YEAR(TODAY()) - 1, MONTH(TODAY()) - 1, 1), 0) -- End at the last day of the previous year's current month
)
)


This will calculate the total units for Jan 2023 to Sep 2023 (PYTD).

 

If this helped, a Kudos 👍 or Solution mark would be great!
Cheers,
Kedar Pande
www.linkedin.com/in/kedar-pande

If this helped, please give Kudos or mark it as a Solution .
Best regards,
Kedar
Connect on LinkedIn

thank you so much, it is working,
is there any way i could use a column where there is a month id like "M001","M002","M003"
i could use the month id column in the end of month like filter.

Hi @newlearnpbi123 

 

Could you please provide some sample data and the expected results based on the sample data so that we can better help you? How to provide sample data in the Power BI Forum - Microsoft Fabric Community Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.

 

Best Regards,
Yulia Xu

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.