Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I would like to create the loop and concatenate the list records in power query function but I'm getting error.
M-Code
(loop as number, T1 as table, CurString as any) => let
CurrentLoop = loop + 1,
T1ColumnCount = 5,
T1ColumnValues = Table.ColumnNames(T1),
CurrentString =if (CurrentLoop = 0) then Text.From(T1ColumnValues{CurrentLoop}) else Text.From(CurString) & Text.From(T1ColumnValues{CurrentLoop}),
OutputString = if (CurrentLoop = T1ColumnCount) then CurrentString else @Query2(CurrentLoop, T1, CurrentString)
in
OutputString
Error:
Expression.Error: There weren't enough elements in the enumeration to complete the operation.
Details:
[List]
Many thanks in advance
I suspect this is due to the fact that counting in power query starts at zero. when you get to loop = 5, you are actually pulling the name of the 6th column, which doesn't exist.
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Bingo! It's working great. But when I make it dynamic like "T1ColumnCount =Table.ColumnCount(T1)" it's showing the below error
Expression.Error: There weren't enough elements in the enumeration to complete the operation.
Details:
[List]
@msksenthil
What is @Query2 in this context?
Can you share the complete file after removing confidential data?
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.