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
KossithAz
Frequent 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
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!

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.