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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Fredde86
Advocate I
Advocate I

Help with NETWORKDAYS counting today as 1, need 0

Hi,

I would like my NETWORKDAYS measure to show 0 if the dates are the same, example below.

Simply adding "- 1" to my measure in the end does not work since it messes up when I have blank rows that I don´t want to include in the calculation.

 

My measure (credit to @Anonymous) : 

 

NetWorkdays *History* = 
    SUMX (
        FILTER (
            MANUFACTURING_ORDERS_HISTORY,
            MANUFACTURING_ORDERS_HISTORY[Order nr (HISTORY)] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Order nr]) &&
            MANUFACTURING_ORDERS_HISTORY[Finish_Item_Number] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Item])
        ),
        NETWORKDAYS (
            MANUFACTURING_ORDERS_HISTORY[Due Date *History*],
            MAX(ITEM_TRANSACTION_HISTORY_SUM[Date])
        )
    )

 

 

The result below and what I want to show in the last column:

 
OrderIDDate (Order completed)Due Date *History*NetWorkdays *History*What I want
10012024-06-082024-06-0810
10022024-06-092024-06-0821

 

Thanks in advance!

1 ACCEPTED SOLUTION

Hi @Fredde86 ,

Please try the bellow DAX measure:

NetWorkdays *History* = 
SUMX(
    FILTER(
        MANUFACTURING_ORDERS_HISTORY,
        MANUFACTURING_ORDERS_HISTORY[Order nr (HISTORY)] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Order nr]) &&
        MANUFACTURING_ORDERS_HISTORY[Finish_Item_Number] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Item])
    ),
    VAR DueDate = MANUFACTURING_ORDERS_HISTORY[Due Date *History*]
    VAR CompletionDate = MAX(ITEM_TRANSACTION_HISTORY_SUM[Date])
    VAR NetworkDays =
        NETWORKDAYS(
            DueDate,
            CompletionDate
        )
    RETURN
        -- Adjust result to match expectations
        IF(
            DueDate = CompletionDate,
            0,
            IF(
                DueDate > CompletionDate,
                NetworkDays - 1,
                NetworkDays + 1
            )
        )
)

 

Please, let me know if you're facing any issue.

 

If this updated measure not works, please provide me a sample data with no sensitive information for your table: MANUFACTURING_ORDERS_HISTORY and ITEM_TRANSACTION_HISTORY_SUM

 

 

 

View solution in original post

6 REPLIES 6
Bibiano_Geraldo
Super User
Super User

Hi @Fredde86 , 

Please try the bellow measure:

NetWorkdays *History* = 
SUMX(
    FILTER(
        MANUFACTURING_ORDERS_HISTORY,
        MANUFACTURING_ORDERS_HISTORY[Order nr (HISTORY)] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Order nr]) &&
        MANUFACTURING_ORDERS_HISTORY[Finish_Item_Number] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Item])
    ),
    IF(
        MANUFACTURING_ORDERS_HISTORY[Due Date *History*] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Date]),
        0,
        NETWORKDAYS(
            MANUFACTURING_ORDERS_HISTORY[Due Date *History*],
            MAX(ITEM_TRANSACTION_HISTORY_SUM[Date])
        )
    )
)

 

Let me know if it works, if no, please provide the sample data with no sensitive data

Hi @Bibiano_Geraldo ,
Thanks for your reply.

Added your configuration to my measure and it solved the problem I was having with same date = 0.
However there are some calculations that doesn´t return desired values, look below:

 

Order nrDateDue Date *History*NetWorkdays *History*Expected output
MALR7602024-01-102024-01-0822
MALT1502024-01-102024-01-0822
MALV8902024-01-102024-01-0921
MAMC2002024-01-102024-01-0921
MAMF2702024-01-102024-01-1000
MAMF8302024-01-102024-01-1000
MAMS0602024-01-102024-01-11-2-1
MAMT0702024-01-102024-01-11-2-1
MAMV9702024-01-102024-01-11-2-1
MAND5302024-01-102024-01-12-3-2
MAND7002024-01-102024-01-12-3-2

 

Hi @Fredde86 ,

Please try the bellow DAX measure:

NetWorkdays *History* = 
SUMX(
    FILTER(
        MANUFACTURING_ORDERS_HISTORY,
        MANUFACTURING_ORDERS_HISTORY[Order nr (HISTORY)] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Order nr]) &&
        MANUFACTURING_ORDERS_HISTORY[Finish_Item_Number] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Item])
    ),
    VAR DueDate = MANUFACTURING_ORDERS_HISTORY[Due Date *History*]
    VAR CompletionDate = MAX(ITEM_TRANSACTION_HISTORY_SUM[Date])
    VAR NetworkDays =
        NETWORKDAYS(
            DueDate,
            CompletionDate
        )
    RETURN
        -- Adjust result to match expectations
        IF(
            DueDate = CompletionDate,
            0,
            IF(
                DueDate > CompletionDate,
                NetworkDays - 1,
                NetworkDays + 1
            )
        )
)

 

Please, let me know if you're facing any issue.

 

If this updated measure not works, please provide me a sample data with no sensitive information for your table: MANUFACTURING_ORDERS_HISTORY and ITEM_TRANSACTION_HISTORY_SUM

 

 

 

Works like a charm, thank you so much! 

 

Happy it works @Fredde86 

Ritaf1983
Super User
Super User

Hi @Fredde86 
just add -1 
in the end of the formula , something like :

NetWorkdays *History* =
SUMX (
FILTER (
MANUFACTURING_ORDERS_HISTORY,
MANUFACTURING_ORDERS_HISTORY[Order nr (HISTORY)] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Order nr]) &&
MANUFACTURING_ORDERS_HISTORY[Finish_Item_Number] = MAX(ITEM_TRANSACTION_HISTORY_SUM[Item])
),
NETWORKDAYS (
MANUFACTURING_ORDERS_HISTORY[Due Date *History*],
MAX(ITEM_TRANSACTION_HISTORY_SUM[Date])-1
)
)

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.



Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

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.