Сначала создайте пару вычисляемых столбцов в вашей календарной таблице:
WorkHours = IF('Calendar'[Holiday] = "Yes", 0, 11)
и
CumulativeHours =
CALCULATE(
SUM('Calendar'[WorkHours]),
ALL('Calendar'),
'Calendar'[Date] <= EARLIER('Calendar'[Date])
)
Я использовал расчетный столбец CreatedDateTime_Updated
CreatedDateTime_Updated =
VAR NextWorkDay =
CALCULATE (
MIN ( 'Calendar'[Date] ),
FILTER ( 'Calendar', 'Calendar'[Date] >= Data[CreatedDateTime].[Date] ),
'Calendar'[Holiday] = "No"
)
RETURN
IF (
HOUR ( Data[CreatedDateTime] ) < 7
|| NextWorkDay > Data[CreatedDateTime].[Date],
NextWorkDay + TIME ( 7, 0, 0 ),
Data[CreatedDateTime]
)
для создания столбца DueDateTime
:
DueDateTime =
VAR CurrentCumulative =
LOOKUPVALUE (
'Calendar'[CumulativeHours],
'Calendar'[Date], Data[CreatedDateTime_Updated].[Date] - 1
)
VAR HoursIntoDay =
ROUND (
24 * ( Data[CreatedDateTime_Updated] - Data[CreatedDateTime_Updated].[Date] )
- 7,
2
)
VAR DueDate =
CALCULATE (
MIN ( 'Calendar'[Date] ),
FILTER (
'Calendar',
'Calendar'[CumulativeHours] >= CurrentCumulative + HoursIntoDay + 33
)
)
RETURN
IF ( HoursIntoDay > 0, DueDate + ( 7 + HoursIntoDay ) / 24, DueDate + 18 / 24 )
Я постараюсь объяснить детали, когда у меня будет время.