Hi @adsa,
In your Expected Result, AssessedToFinalised Days shows 1, but 4-4-2021 isn’t a working day. Therefore, in the solution below, it returns 0. Adjust if necessary. Give this a go:
let
listWorkdays = List.Buffer( Table.SelectRows( #"Date Table", each [IsWeekDay] =1)[Date] ),
fxWorkdayCount = (workdayList as list, optional startDate as date, optional endDate as date) as number =>
List.Count( List.Select( workdayList, (x)=> x >= startDate and x <= endDate )),
Source = Summary,
ChType = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Created", type date}, {"Submitted", type date}, {"Assessed", type date}, {"Finalised", type date}}),
AddFields = Table.AddColumn(ChType, "NewFields", each [
CreatedToSubmitted Days = fxWorkdayCount( listWorkdays, [Created], [Submitted]),
SubmittedToAssessed Days = fxWorkdayCount( listWorkdays, [Submitted], [Assessed]),
AssessedToFinalised Days = fxWorkdayCount( listWorkdays, [Assessed], [Finalised])
], type [
CreatedToSubmitted Days = Int64.Type,
SubmittedToAssessed Days = Int64.Type,
AssessedToFinalised Days = Int64.Type
]
),
ExpandFields = Table.ExpandRecordColumn(AddFields, "NewFields",
{"CreatedToSubmitted Days", "SubmittedToAssessed Days", "AssessedToFinalised Days"}
)
in
ExpandFields
Let me know how this compares performace wise.
I hope this is helpful