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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
KossithAz
Helper I
Helper I

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
Resident Rockstar
Resident Rockstar

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
Resident Rockstar
Resident Rockstar

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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