Forum Discussion
Help with NETWORKDAYS counting today as 1, need 0
- 1 year ago
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
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
- Fredde861 year ago
Advocate I
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 nr Date Due Date *History* NetWorkdays *History* Expected output MALR760 2024-01-10 2024-01-08 2 2 MALT150 2024-01-10 2024-01-08 2 2 MALV890 2024-01-10 2024-01-09 2 1 MAMC200 2024-01-10 2024-01-09 2 1 MAMF270 2024-01-10 2024-01-10 0 0 MAMF830 2024-01-10 2024-01-10 0 0 MAMS060 2024-01-10 2024-01-11 -2 -1 MAMT070 2024-01-10 2024-01-11 -2 -1 MAMV970 2024-01-10 2024-01-11 -2 -1 MAND530 2024-01-10 2024-01-12 -3 -2 MAND700 2024-01-10 2024-01-12 -3 -2 - Bibiano_Geraldo1 year ago
Super User
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
- Fredde861 year ago
Advocate I
Works like a charm, thank you so much!