Forum Discussion
Calculate when start production (excluding weekends)
- Anonymous4 years ago
Hi Adamplau ,
You can update the formula of the calculated column [Prod. Start Date (exc. weekends)] as below in the table 'Orders' and check if it can return your expected result... It is not required to create any relationship between the table 'Orders' and 'Date' table.
Prod. Start Date (exc. weekends) = VAR DateIdx = CALCULATE ( MAX ( 'Date'[WorkingDayIndex] ), FILTER ( 'Date', 'Date'[Date] = 'Orders'[ProductionDueDate] ) ) VAR NewDateIdx = DateIdx - 'Orders'[ProdactionDurationInDays] RETURN CALCULATE ( MAX ( 'Date'[Date] ), FILTER ( ALL ( 'Date' ), 'Date'[WorkingDayIndex] = NewDateIdx && 'Date'[IsWorkingDay] = TRUE() ) )Best Regards
I have this working, however I need to have active relationship between Date and Orders tables.
How to change it and activate the relationship in the script using USERELATIONSHIP?
Prod. Start Date (exc. weekends) =
VAR DateIdx =
CALCULATE(
MAX( 'Date'[WorkingDayIndex] ),
'Orders'[ProductionDueDate] = RELATED('Date'[Date] )
)
VAR NewDateIdx = DateIdx - 'Orders'[ProdactionDurationInDays]
RETURN
CALCULATE(
MAX('Date'[Date]),
FILTER(
ALL('Date'),
'Date'[WorkingDayIndex] = NewDateIdx
&& 'Date'[IsWorkingDay] = TRUE()
)
)
Hi Adamplau ,
You can update the formula of the calculated column [Prod. Start Date (exc. weekends)] as below in the table 'Orders' and check if it can return your expected result... It is not required to create any relationship between the table 'Orders' and 'Date' table.
Prod. Start Date (exc. weekends) =
VAR DateIdx =
CALCULATE (
MAX ( 'Date'[WorkingDayIndex] ),
FILTER ( 'Date', 'Date'[Date] = 'Orders'[ProductionDueDate] )
)
VAR NewDateIdx = DateIdx - 'Orders'[ProdactionDurationInDays]
RETURN
CALCULATE (
MAX ( 'Date'[Date] ),
FILTER (
ALL ( 'Date' ),
'Date'[WorkingDayIndex] = NewDateIdx
&& 'Date'[IsWorkingDay] = TRUE()
)
)
Best Regards
- Adamplau4 years agoNew Member
It's working. Thanks.