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
sannadisarath
New Member

difference between two days excluding weekends

Hi All,

 

I want to get difference between two dates excluding weekends, please let me know what could be the formula.

i am pulling data from sharepoint online.

 

Thanks,
Sarath.

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi sannadisarath,

 

According to your description, you want to get a date list between two dates except weekends, right?

 

If as I said, you can follow below steps:

1. Use CALENDAR function to create a datetable with two dates.

 

Dax: DateTable = CALENDAR(DATE(2010,1,1),TODAY())

Capture.PNG

 

2. Write dax formula to get the specify dates without weekends.

 

Dax: Date Except Weekends = CALCULATETABLE(DateTable,FILTER(ALL(DateTable), AND(WEEKDAY([Date],1)<> 1,WEEKDAY([Date],1)<> 7))) (Notice: 1 is Sunday, 7 is Saturday)

 

Capture2.PNG

 

I added a calculate column to show the day of week.

 

Reference:

WEEKDAY Function (DAX)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
ssvr
Helper III
Helper III

Hi,

DDiff.JPG

I created a Date table:

 

Dim Table=CALENDAR(DATE(2008,1,1),DATE(2018,12,31))

 

I created a new column with is working day or not

 

is work day = SWITCH(WEEKDAY([Date]),1,0,7,0,1)

 

Now I want to create "DateDifference" Column with Createddate & Closeddate (I want to know day diffarence b/w these two dates excluding weekends)

 

CreatedDate   ClosedDate  DateDiffarence

v-shex-msft
Community Support
Community Support

Hi sannadisarath,

 

According to your description, you want to get a date list between two dates except weekends, right?

 

If as I said, you can follow below steps:

1. Use CALENDAR function to create a datetable with two dates.

 

Dax: DateTable = CALENDAR(DATE(2010,1,1),TODAY())

Capture.PNG

 

2. Write dax formula to get the specify dates without weekends.

 

Dax: Date Except Weekends = CALCULATETABLE(DateTable,FILTER(ALL(DateTable), AND(WEEKDAY([Date],1)<> 1,WEEKDAY([Date],1)<> 7))) (Notice: 1 is Sunday, 7 is Saturday)

 

Capture2.PNG

 

I added a calculate column to show the day of week.

 

Reference:

WEEKDAY Function (DAX)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.