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
KossithAz
Regular Visitor

Calulate months open but considers dates with end dates and those with none

Hi folks,

Looking at a dataset where I'm trying to work out the duration of months open from the start date.

Example:

Start dateEnd dateMonths Open
05 December 202310 December 2023 
06 May 202201 April 2023 
07 November 2022  

 

I was previously using 

Months open = DATEDIFF('inYear'[Start date],TODAY(),MONTH)

But sadly this keeps adding months onto those that have ended.

So ideally, I need the months since the start date, but stops for those with an end date and continues on for those without an end date.
1 ACCEPTED SOLUTION
DOLEARY85
Super User
Super User

Hi,

 

try something like this:

 

Months Open = IF( ISBLANK('inYear'[End date]), DATEDIFF('inYear'[Start date], TODAY(), MONTH), DATEDIFF('inYear'[Start date], 'inYear'[End date], MONTH) )

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

View solution in original post

2 REPLIES 2
DOLEARY85
Super User
Super User

Hi,

 

try something like this:

 

Months Open = IF( ISBLANK('inYear'[End date]), DATEDIFF('inYear'[Start date], TODAY(), MONTH), DATEDIFF('inYear'[Start date], 'inYear'[End date], MONTH) )

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Thank you, that has worked wonderful!

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.