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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Elder22
Frequent Visitor

DATEDIFF help

Hi,

 

I have searched the forums for the problem I am having and cannot seem to find the exact problem, so hope you can help!

 

I am trying to work out the difference between two dates in months, so I can calculate all opportunities due to close this month, and the next two months.

 

I use this formula:

 

DateDiff = DATEDIFF(Opportunity[Close Date],TODAY(),MONTH)

 

However I get the error message " In DATEDIFF function, the start date cannot be greater than the end date", but I expect this - as some oportunities may be closed in the past we wll as the future. How can I solve this so opportunities can be identified in the next 3 months? Even if past opportunities were negative values, for instance.

 

Any help appreciated - thanks.

1 ACCEPTED SOLUTION
vanessafvg
Super User
Super User

@Elder22 so do you want to ignore the opportunity dates that are > than today?

 

if so its really quite simple, you can ignore it until its relevant

 

 

DateDiff =
IF (
    TODAY () > Opportunity[Close Date],
    DATEDIFF ( Opportunity[Close Date], TODAY ()MONTH ),
    0
)

 

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
vanessafvg
Super User
Super User

@Elder22 so do you want to ignore the opportunity dates that are > than today?

 

if so its really quite simple, you can ignore it until its relevant

 

 

DateDiff =
IF (
    TODAY () > Opportunity[Close Date],
    DATEDIFF ( Opportunity[Close Date], TODAY ()MONTH ),
    0
)

 

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hello,

 

Thanks for your response - this worked fine for me, thanks very much I will mark as solved.

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.