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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Exclude Start date in Datesbetween Function

How to exclude start date in below function

Days= CALCULATE( COUNTROWS(DateDim) , DATESBETWEEN( DateDim[ActualDate], All[SartDate],'All'[EndDate]),
All(All)
)
EX: StartDate = 1/9/2019
EndDate = 1/14/2019
Days Diff = 6 (Need 5 exclude start Date)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

The formula "weekday(DateDim[ActualDate],2)<=5) " is used to get the dates which is working day. You can refer this documentation about the details of function WEEKDAY .

You can update the formula of the related calculated column as below:

Daysdiff=
var a= DATEDIFF('All'[StartDate],'All'[EndDate], DAY) -
(
   CALCULATE (
        COUNTROWS('DateDim'),
        WEEKDAY('DateDim'[ActualDate],2)>5,
        DATESBETWEEN('DateDim'[ActualDate], 'All'[StartDate], 'All'[EndDate])
   )
) 
return 
if(a<0,0,a)

daysdiff.JPG

Best Regards

Rena

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi @Anonymous ,

Please try to use the function DATEDIFF

Days = DATEDIFF ( All[SartDate], 'All'[EndDate], DAY )

Best Regards

Rena

Anonymous
Not applicable

Using DateDiff, how can I exclude weekends? 

Anonymous
Not applicable

Hi @Anonymous ,

What is your expected result? You want the number of days between StartDate and EndDate exclude weekends? If yes, please check if the following screenshot is your expected result?

datediff.JPG

And you refer the start date need to be excluded, then the final days between 1/9/2019 and 1/14/2019 should be 3 not 5 since it need to exclude weekends and start date....

Best Regards

Rena

Anonymous
Not applicable

Yes expected result is 3. Could you explain why you used

weekday(DateDim[ActualDate],2)<=5)  at the end.
 
Also using DateDiff is there a way to exclude Weekends? As I dont want any hardcoding like (-1) in the syntax

Thanks 

Anonymous
Not applicable

Hi @Anonymous ,

The formula "weekday(DateDim[ActualDate],2)<=5) " is used to get the dates which is working day. You can refer this documentation about the details of function WEEKDAY .

You can update the formula of the related calculated column as below:

Daysdiff=
var a= DATEDIFF('All'[StartDate],'All'[EndDate], DAY) -
(
   CALCULATE (
        COUNTROWS('DateDim'),
        WEEKDAY('DateDim'[ActualDate],2)>5,
        DATESBETWEEN('DateDim'[ActualDate], 'All'[StartDate], 'All'[EndDate])
   )
) 
return 
if(a<0,0,a)

daysdiff.JPG

Best Regards

Rena

Anonymous
Not applicable

Thanks for the solution. It Worked, but for some reason "weekday(DateDim[ActualDate],2)<=5)  is not working for me, so instead I used 'DateDim'[IsWeekend] = TRUE().

 

Anonymous
Not applicable

Thanks for the solution. It Worked, but for some reason "weekday(DateDim[ActualDate],2)<=5)  is not working for me, so instead I used 'DateDim'[IsWeekend] = TRUE().

Daysdiff=
var a= DATEDIFF('All'[StartDate],'All'[EndDate], DAY) -
(
CALCULATE (
COUNTROWS('DateDim'),

DATESBETWEEN('DateDim'[ActualDate], 'All'[StartDate], 'All'[EndDate]),
'DateDim'[IsWeekend] = TRUE()
)
)
return
if(a<0,0,a)

 

Anonymous
Not applicable

Using DateDiff, how can I exclude weekends? 

Greg_Deckler
Community Champion
Community Champion

Column = ([EndDate] - [StartDate]) * 1.

 

Measure = (MAX([EndDate]) - MAX([StartDate])) * 1.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Not Working

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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