Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi
this is the error shown
I then get a full table of results when i transform to a table (showing no errors in any rows (it works perfectly as intended)
Code for the list.generate is
= List.Generate(
()=>[
RotaType = #"Rota_Data (2)"{CR}[RotaType],
RotaSlotType = #"Rota_Data (2)"{CR}[RotaSlotType],
Duration = #"Rota_Data (2)"{CR}[Duration],
Index = #"Rota_Data (2)"{CR}[Index],
CR = 0,
NR = 1,
EX = -1,
CRRotaName = #"Rota_Data (2)"{CR}[ROTA],
NRRotaName = #"Rota_Data (2)"{NR}[ROTA],
CRTime = #"Rota_Data (2)"{CR}[TimeStart],
NRTime = #"Rota_Data (2)"{NR}[TimeStart],
ActualPosition = 1
],
each [CR] < List.Max(#"Rota_Data (2)"[Index]),
each
if
[ActualPosition] <>1 and [CRRotaName] <> [NRRotaName]
then [
RotaType = #"Rota_Data (2)"{CR}[RotaType],
RotaSlotType = #"Rota_Data (2)"{CR}[RotaSlotType],
Duration = #"Rota_Data (2)"{CR}[Duration],
Index = #"Rota_Data (2)"{CR}[Index],
CR = [CR] +1,
NR = [NR] +1,
EX = [CR] ,
CRRotaName = #"Rota_Data (2)"{CR}[ROTA],
NRRotaName = #"Rota_Data (2)"{NR}[ROTA],
CRTime = #"Rota_Data (2)"{CR}[TimeStart],
NRTime = #"Rota_Data (2)"{NR}[TimeStart],
ActualPosition = [ActualPosition]+1
]
else [
RotaType = #"Rota_Data (2)"{CR}[RotaType],
RotaSlotType = #"Rota_Data (2)"{CR}[RotaSlotType],
Duration = #"Rota_Data (2)"{CR}[Duration],
Index = #"Rota_Data (2)"{CR}[Index],
CR = [CR] +1,
NR = [NR] +1,
EX = [EX] +1,
CRRotaName = #"Rota_Data (2)"{CR}[ROTA],
NRRotaName = #"Rota_Data (2)"{NR}[ROTA],
CRTime = [CRTime] + #"Rota_Data (2)"{EX}[Actual Duration],
NRTime = #"Rota_Data (2)"{NR}[TimeStart],
ActualPosition = [ActualPosition]+1
]
)
It looks through and adds a duration to the time of the next line based on whether or not its the same Rota or not (all the rota outputs is a start time)
I noticed the error when i expanded a merge into another query table.
The error shown on that table is
An error occurred in the ‘DurationList’ query. Expression.Error: There weren't enough elements in the enumeration to complete the operation.
Details:
[Table]
Any help appreciated
"please ignore the ess, im just working on a copy so its gotten a bit messy"
Solved! Go to Solution.
Thank you for the advice it turned out to be
each [CR] < List.Max(#"Rota_Data (2)"[Index]),
I needed to amend it to NR instead as CR did not reach the maximum value until one step after the end
I can't tell precisely where the problem is but I'm betting it's an off-by-one indexing error where you're trying to pull
#"Rota_Data (2)"{CR}[ColName]
where CR is greater than the maximal index of Rota_Data (2).
Thank you for the advice it turned out to be
each [CR] < List.Max(#"Rota_Data (2)"[Index]),
I needed to amend it to NR instead as CR did not reach the maximum value until one step after the end