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
kmax
Helper I
Helper I

DateDiff is counting 13 months for previous year

Hi,
I am working to count number of months as below.

 

StartDate           EndDate          TotalMonths
26-dec-2023     25-dec-2024    13
30-nov-2023     30-nov-2024    13
01-jan-2024      31-dec-2024    12

Dax formula is 
DATEDIFF(
StartDate,
EndDate,
MONTH
) +1
If I remove +1, it shows 11 months for current year data. Adding +1 in datediff works fine for current year but adds an extra month where startdate is in previous years.
How can I fix this issue.
Thanks in advance

1 ACCEPTED SOLUTION
Vallirajap
Resolver III
Resolver III

Hi @kmax 

 

Try this, you can use the below dax to create  a new measure to solve the issue.

Total Months = DATEDIFF([StartDate]-1, [EndDate], MONTH)

 

Vallirajap_0-1705556106237.png

 

Did I answer your question?

Mark my post as a solution, this will help others...!

Hit the kudo also,

Thank you.

 

View solution in original post

1 REPLY 1
Vallirajap
Resolver III
Resolver III

Hi @kmax 

 

Try this, you can use the below dax to create  a new measure to solve the issue.

Total Months = DATEDIFF([StartDate]-1, [EndDate], MONTH)

 

Vallirajap_0-1705556106237.png

 

Did I answer your question?

Mark my post as a solution, this will help others...!

Hit the kudo also,

Thank you.

 

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!

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.