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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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
Super User
Super User

@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

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
Super User
Super User

@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

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.