Forum Discussion
Add Work Days with Custom Calendar
- Anonymous1 year ago
Hi datachick2024 ,
Thanks for amitchandak's reply!
And datachick2024 , here is my sample data (To save time, I use 45702Site X for all Date_Site_Key here):Because I don't know what your data model looks like, I didn't create Dim Date Table.
Then I use this DAX to create a measure:Est_Ship_Date = VAR OrderDate = SELECTEDVALUE('End Date'[Order Date]) VAR CurrentSite = SELECTEDVALUE('End Date'[Site]) VAR DelayWD = SELECTEDVALUE('End Date'[Shipment_Delay_WD]) VAR CurrentKey = SELECTEDVALUE('End Date'[Date_Site_Key]) VAR WorkingDaysAfterOrder = CALCULATETABLE( ADDCOLUMNS( FILTER( 'Working Day', 'Working Day'[Site] = CurrentSite && 'Working Day'[Date_Site_Key] = CurrentKey && 'Working Day'[Date] >= OrderDate && 'Working Day'[Working Day] = "Yes" ), "CumulativeWorkDays", RANKX( FILTER( 'Working Day', 'Working Day'[Site] = CurrentSite && 'Working Day'[Date_Site_Key] = CurrentKey && 'Working Day'[Date] >= OrderDate && 'Working Day'[Working Day] = "Yes" ), 'Working Day'[Date], , ASC ) ) ) VAR EstimatedDate = MAXX( FILTER( WorkingDaysAfterOrder, [CumulativeWorkDays] = DelayWD ), 'Working Day'[Date] ) RETURN EstimatedDateAnd the final output is as below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is helpful, thank you. However, I need to be able to make the "10" to a dynamic value as well
Hi datachick2024 ,
Thanks for amitchandak's reply!
And datachick2024 , here is my sample data (To save time, I use 45702Site X for all Date_Site_Key here):
Because I don't know what your data model looks like, I didn't create Dim Date Table.
Then I use this DAX to create a measure:
Est_Ship_Date =
VAR OrderDate = SELECTEDVALUE('End Date'[Order Date])
VAR CurrentSite = SELECTEDVALUE('End Date'[Site])
VAR DelayWD = SELECTEDVALUE('End Date'[Shipment_Delay_WD])
VAR CurrentKey = SELECTEDVALUE('End Date'[Date_Site_Key])
VAR WorkingDaysAfterOrder =
CALCULATETABLE(
ADDCOLUMNS(
FILTER(
'Working Day',
'Working Day'[Site] = CurrentSite &&
'Working Day'[Date_Site_Key] = CurrentKey &&
'Working Day'[Date] >= OrderDate &&
'Working Day'[Working Day] = "Yes"
),
"CumulativeWorkDays",
RANKX(
FILTER(
'Working Day',
'Working Day'[Site] = CurrentSite &&
'Working Day'[Date_Site_Key] = CurrentKey &&
'Working Day'[Date] >= OrderDate &&
'Working Day'[Working Day] = "Yes"
),
'Working Day'[Date],
,
ASC
)
)
)
VAR EstimatedDate =
MAXX(
FILTER(
WorkingDaysAfterOrder,
[CumulativeWorkDays] = DelayWD
),
'Working Day'[Date]
)
RETURN
EstimatedDate
And the final output is as below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.