Reply
manojnikam3008
Frequent Visitor

Calculate Net Working Days

Hi Experts,

 

I am trying to calculate net working days between two dates that I'am capturing from slicer but somehow i am not getting the expected output.

 

Objective: I want to capture dates from the slicer and return net working days between that date range + i want to calculate user capacity (i.e per day working hours of user) during that date range (E.g - If user selects 10 days period in slicer, I want to return 1. Net working Days + 2. Daily working hours x 10 days = 80 + 3. I require this to calculate if user has booked 80 hours during 10 days or not -if less then i will show them Insufficient hours and vice versa)

 

Table name: Timesheet (62)

Column Name: Date

Column Name: 'Timesheet (62)'[IsWorkingDay]

Slicer using the [Date] Column.

Measures used: (this is done to keep it dynamic in nature upon user's selection of the specific date range)

Start date of filter = Capturing Start date of the slicer in using FIRSTDATE function
End date of filter = Capturing End date of the slicer in using FIRSTDATE function

 

DAX: 

WorkingDays = CALCULATE(COUNTROWS('Timesheet (62)'),DATESBETWEEN('Timesheet (62)'[Date],[Start Date of filter],[End Date of filter]),'Timesheet (62)'[IsWorkingDay]="True")
 
Is it allowed to use measures in this formula, if so then it's not filtering the data. I get the total of 11713 i.e. the toal of all TRUE values from [IsWorkingDay] column. 
 
Image for referenceImage for reference
 
Appreciate your response on this.
 
Thanks in advance!
 
- Manoj Nikam
1 ACCEPTED SOLUTION
edhans
Super User
Super User

Hi @manojnikam3008 - with a Date table this becomes really easy. 
The measure is this:

 

Working Days = 
CALCULATE(
    COUNTROWS('Date'),
    'Date'[IsWorkingDay] = TRUE()
)

 

You can then create another measure to multiply that measure by 8 or whatever to get hours.

edhans_0-1627403780703.png

See the file here for how this works.
You'll notice I have filtered the date slicer by valid data in the fact table:

edhans_1-1627403980093.png

Valid Data is just a measure that is COUNTROWS(Timesheets) - if there are records, the slicer will show it. Future and past dates though won't show up.

If that isn't what you want, please provide more specifics per the info below. But the point is with a good date dimension table, the DAX becomes very easy.

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
manojnikam3008
Frequent Visitor

Thank You! New date table worked.

Perfect @manojnikam3008 

Rule of thumb - if your data has dates, create a date table for just this sort of thing. Glad your project is moving forward!



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Got it! Thanks for this 🙂

edhans
Super User
Super User

Hi @manojnikam3008 - with a Date table this becomes really easy. 
The measure is this:

 

Working Days = 
CALCULATE(
    COUNTROWS('Date'),
    'Date'[IsWorkingDay] = TRUE()
)

 

You can then create another measure to multiply that measure by 8 or whatever to get hours.

edhans_0-1627403780703.png

See the file here for how this works.
You'll notice I have filtered the date slicer by valid data in the fact table:

edhans_1-1627403980093.png

Valid Data is just a measure that is COUNTROWS(Timesheets) - if there are records, the slicer will show it. Future and past dates though won't show up.

If that isn't what you want, please provide more specifics per the info below. But the point is with a good date dimension table, the DAX becomes very easy.

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)