cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TinyElephant
Helper II
Helper II

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



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

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
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

Power BI Dev Camp Session 25 with aka link 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, August 25 at 11a PDT for a great session with Ted Pattison!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors