Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
drake
Frequent Visitor

Networkdays

HI Guys new to this so trying to translate my excel skills to DAX !

 

I have two date columns and i want the working days between

iecolum A 1-june-2016   and column B 30-December 2016

current using the DATEDIFF ftn which is a good starting point

 

What im looking for is help with is :

a) how to deal with a a missing date - i want 0 for that row

b)if the date in colum A is greater thab B to rerun a negaive value

 

iwoould like to see something like that below giving results in column C

     A                  B                   C

1/1/16          14/1/16           10 [ Working days]

1/1/16           BLANK              0

14/1/16         1/1/16            -10

 

Hope thats clear - thanks 

 

1 ACCEPTED SOLUTION

@drake

 

In this scenario, you need to have a full calendar date table, then add a column to tag if the date is working day.

 

IsWorkingDay = IF(WEEKDAY('Calendar'[Date],2)>5,0,1)

8.PNG

 

 

Then you can create a calculated column like below:

 

NetWorkingDays =
IF (
    ISBLANK ( DateRange[StartDate] ) || ISBLANK ( DateRange[EndDate] ),
    0,
    IF (
        DateRange[StartDate] <= DateRange[EndDate],
        CALCULATE (
            COUNT ( 'Calendar'[IsWorkingDay] ),
            DATESBETWEEN ( 'Calendar'[Date], DateRange[StartDate], DateRange[EndDate] )
        ),
        - CALCULATE (
            COUNT ( 'Calendar'[IsWorkingDay] ),
            DATESBETWEEN ( 'Calendar'[Date], DateRange[EndDate], DateRange[StartDate] )
        )
    )
)

99.PNG

 

 

Regards,

View solution in original post

4 REPLIES 4
mattbrice
Solution Sage
Solution Sage

Networkdays = IF ( ISBLANK ( table[Date A] ) || ISBLANK ( table[Date B] ), 0, DATEDIFF ( table[Date A], table[Date B], day ) )

thanks - i had this but im not sure if your formula - [which is cleverer than mine !]  will return network days or calander days ?

 

 

APP 2 Posting = if(OR
('Data'[First Fully Approved Date]=0,'Data'[First Sourced Date]=0)
,0,
(DATEDIFF
('Data'[First Fully Approved Date].[Date],'Data'[First Sourced Date].[Date],DAY)
))

@drake

 

In this scenario, you need to have a full calendar date table, then add a column to tag if the date is working day.

 

IsWorkingDay = IF(WEEKDAY('Calendar'[Date],2)>5,0,1)

8.PNG

 

 

Then you can create a calculated column like below:

 

NetWorkingDays =
IF (
    ISBLANK ( DateRange[StartDate] ) || ISBLANK ( DateRange[EndDate] ),
    0,
    IF (
        DateRange[StartDate] <= DateRange[EndDate],
        CALCULATE (
            COUNT ( 'Calendar'[IsWorkingDay] ),
            DATESBETWEEN ( 'Calendar'[Date], DateRange[StartDate], DateRange[EndDate] )
        ),
        - CALCULATE (
            COUNT ( 'Calendar'[IsWorkingDay] ),
            DATESBETWEEN ( 'Calendar'[Date], DateRange[EndDate], DateRange[StartDate] )
        )
    )
)

99.PNG

 

 

Regards,

Hi

 

Thanks a lot  for your formula, but there is a small issue I found that instead of using COUNT I used SUM now it is working fineSmiley Happy

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors