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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
TMO_KY
Helper II
Helper II

Calculate dates between 2 dates but exclude Start / End date

I have an interesting ask, I have a code that I use to find dates between 2 given dates; 

= Table.AddColumn(#"Renamed Columns", "Work Days", each { Number.From([First Date])..Number.From([Last Date]) })

 

What I want to do, is extract the dates between the 2 columns (First Date, Last Date) and exclude those given dates.  For example if the Start Date is 1/1/2020 and the Last Date is 1/10/2020.  I only want to return the dates 1/2/2020-1/9/2020 in my data.  Is this possible?  Currently it expands all rows which is fine but it includes the start and last date; however these dates are never the same and can change based on project length which is why I can't use any workday formulas.  The exlusion doesn't have to be within the same formula, I can always add another step after if that's easier.  I'm just stumped on how to make it work.

 

TMO_KY_0-1596477476377.png

 

1 ACCEPTED SOLUTION
arq52
Frequent Visitor

Hello,

use Date.AddDays ;

Table.AddColumn(#"Renamed Columns", "Work Days", each { Number.From(Date.AddDays([First Date],1))..Number.From(Date.AddDays([Last Date],-1)) })

Best regards

View solution in original post

4 REPLIES 4
arq52
Frequent Visitor

Hello,

use Date.AddDays ;

Table.AddColumn(#"Renamed Columns", "Work Days", each { Number.From(Date.AddDays([First Date],1))..Number.From(Date.AddDays([Last Date],-1)) })

Best regards

@arq52  Much appreciated!  Now I have less steps in my query.  🙂

amitchandak
Super User
Super User

@TMO_KY , refer if this file can help a bit https://www.dropbox.com/s/bqbei7b8qbq5xez/leavebetweendates.pbix?dl=0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
TMO_KY
Helper II
Helper II

*Update*  

So I ended up creating an additional custom column that uses a filter with a true false statement then filtered out the "true's".  This works but if anyone has a better workaround with less "steps" I'd appreciate it.

 

TMO_KY_0-1596478354086.png

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.