Skip to main content

Power BI

New

Please add the networkdays function in Excel to DAX

Vote (47) Share
Conrad Wong's profile image

Conrad Wong on 24 Apr 2015 01:40:13

Comments (7)
Conrad Wong's profile image Profile Picture

4ef02159 8a2e-4f49-9b21-ed21b5abeafc on 06 Jul 2020 00:13:37

RE: Please add the networkdays function in Excel to DAX

But it doesnot work if one of the date is blank or nulldate. is there anyway we can calculate the days between two dates column when some of the value is blank.

Conrad Wong's profile image Profile Picture

1287375e 7542-4d6c-8d04-74577b8228eb on 05 Jul 2020 23:52:29

RE: Please add the networkdays function in Excel to DAX

It's not a hard issue to work around, but something that shouldn't require a work around. All current solutions rely on non-standard holiday table locations. If there was a Microsoft provided standard solution, there'd be a universal method we'd be able to use to reproduce this fairly basic functionality. There's data still living in Excel that I'm reluctant to move for this specific reason.

Conrad Wong's profile image Profile Picture

a9528410 5438-48b6-a4bd-227f31374d70 on 05 Jul 2020 23:14:47

RE: Please add the networkdays function in Excel to DAX

I added this to the Quick Measure Gallery here:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Net-Work-Days/m-p/367362

Conrad Wong's profile image Profile Picture

d7d02435 0137-4987-8e2e-81fc82a11dcd on 05 Jul 2020 23:10:23

RE: Please add the networkdays function in Excel to DAX

Aside from being really useful (so should have been added by now?), why are there functions in Excel that are not in Power BI?

Conrad Wong's profile image Profile Picture

4d63306d ad4a-444b-bffc-5386eb72c5cc on 05 Jul 2020 22:52:30

RE: Please add the networkdays function in Excel to DAX

Yes agree I have been able to use a date calendar and holidays and sum working days but is very complex for what should be fundamental capability and simple function, still can't do it natively in SharePoint online!

https://community.powerbi.com/t5/Desktop/Number-of-working-days/td-p/22842

Conrad Wong's profile image Profile Picture

e9166ce2 9dac-46b5-8a64-eee9e9aaca19 on 05 Jul 2020 22:32:04

RE: Please add the networkdays function in Excel to DAX

Hi,

The proposed solution by the admin is working if we have only one data, but if we are talking about 2 dates (start date and end date) and we need measure the working days between both dates this solution will not work

Conrad Wong's profile image Profile Picture

3710de78 2954-4c5f-ac3c-a30f062cca21 on 05 Jul 2020 22:00:14

RE: Please add the networkdays function in Excel to DAX

Hi Conrad,

We don't have this on the immediate backlog but it is pretty straightforward to do in DAX. This should do the trick if you want to filter out Saturday and Sunday:
Measure = CALCULATE(COUNTROWS('Calendar'),
FILTER('Calendar', WEEKDAY('Calendar'[Date]) > 1
&& WEEKDAY('Calendar'[Date]) < 7 ))

There are even easier ways to do this using a calculated column or Power Query where you add a column to check if a date is a working day. This will simplify the DAX above.