Forum Discussion

bdehning's avatar
bdehning
Post Prodigy
2 years ago

Networkdays

I tried using the following but it is one day off due to February 29th this year I beleive.  I got total days of 106 but it should be 107? 

 

WorkingDaysFriSatHolidays =
VAR _holidays = {DATE(2024, 01, 1), DATE(2024, 01, 15), DATE(2024, 05, 27)}

RETURN NETWORKDAYS(DATE(2024, 01, 1), dt"2024-05-31", 7, _holidays)

 

What am I missing?  

5 Replies

    • Greg_Deckler's avatar
      Greg_Deckler
      Community Champion

      bdehning OK, did some testing. I believe the issue is that you specified 7 in the third parameter meaning that weekends are Friday and Saturday. 5/31/2024 falls on a Friday. See attached PBIX where I did some tests with 2/29/2024 and then Table2 shows an counter in Column 2 for all previous weekdays. It comes out to 109. So that minus 3 is 106

      • bdehning's avatar
        bdehning
        Post Prodigy

        Greg,   How do I incorporate my Date of Service Filter

        Date of Service =
        VAR dte =
        DATE(
            INT(isiInspections[DateOfService] / 10000)
            , MOD(INT(isiInspections[DateOfService] / 100), 100)
            , MOD(isiInspections[DateOfService], 100)
        )
        RETURN
        IF(
            dte < TODAY()
            , dte
        )

         

        So it will control my Card or be a mesure that provides number of working days.

           

        Working Days =
        VAR _FirstDate = MIN('VW_DATE_DIM'[Date])
        Var _LastDate = MAX('VW_DATE_DIM'[Date])
        Var _Holidays =CALCULATETABLE(
                DISTINCT('VW_DATE_DIM'[DATE]),
                'VW_DATE_DIM'[ISHOLIDAY] = 1)

        RETURN

        NETWORKDAYS(
           _FirstDate,
           _LastDate,
            1,
            _Holidays)