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
TinyElephant
Helper III
Helper III

Calculate number of work days

Hello,

I have gone through some of the posts on this forum. Please have a look at my table.

I want to calculate the number of work days for the series of "Date", i.e. exclude Saturdays, Sundays, and "Holiday" (in Work column). There may not be a holiday in a particular Date Range.

 

 

TinyElephant_0-1628833359443.png

 

EmployeeWorkHoursDate
Person 1Task 1409-Aug-21
Person 1No Work209-Aug-21
Person 1Task 2209-Aug-21
Person 2Task1309-Aug-21
Person 2Task 2109-Aug-21
Person 2Leave409-Aug-21
Person 3No Work309-Aug-21
Person 3Task 2509-Aug-21
Person 1Holiday810-Aug-21
Person 2Holiday810-Aug-21
Person 3Holiday810-Aug-21
Person 1Task 2811-Aug-21
Person 2Task 3811-Aug-21
Person 3Task 4811-Aug-21
Person 1Task 2812-Aug-21
Person 2Task 3812-Aug-21
Person 3Task 2812-Aug-21
1 ACCEPTED SOLUTION

Hi @TinyElephant ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

Create the below 2 measures to get the number of work days:

Number of work days = 
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Date] ),
    FILTER (
        'Table',
        'Table'[Work] <> "Holiday"
            && WEEKDAY ( 'Table'[Date], 2 ) < 6
    )
)
Measure = SUMX(VALUES('Table'[Employee]),[Number of work days])

yingyinr_0-1629098940722.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@TinyElephant , between which range you wany workday?

Not very clear with example

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

The dates are mentioned in the Date column. In the image here you can see the date entries from 09 Aug 2021 to 12 Aug 2021. I don't want to manually mention the start and end date but to automatically pick it up from the Date column.
Later I would like to control the dashboard visuals using a Date Ranger slider.

Hi @TinyElephant ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

Create the below 2 measures to get the number of work days:

Number of work days = 
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Date] ),
    FILTER (
        'Table',
        'Table'[Work] <> "Holiday"
            && WEEKDAY ( 'Table'[Date], 2 ) < 6
    )
)
Measure = SUMX(VALUES('Table'[Employee]),[Number of work days])

yingyinr_0-1629098940722.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the 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.