Forum Discussion
Loop through the table in M query
- 6 years ago
Hello Anonymous
you can use List.Accumulate to accomplish your task.
Here the complete solution
let Source = #table ( {"Title.Name","Value.Attributes.L01"}, { {"Name1","Australia"}, {"Name2","Volkwagen"} } ), CellValue = #table ( {"Cell.Value"}, { {"1"}, {"5"}, {"6"} } ), ListAccumulate = List.Accumulate ( {0..Table.RowCount(Source)-1}, CellValue, (old,current)=> Table.AddColumn(old, Source[Title.Name]{current}, each Source[Value.Attributes.L01]{current} ) ) in ListAccumulateCopy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello Anonymous
you can use List.Accumulate to accomplish your task.
Here the complete solution
let
Source = #table
(
{"Title.Name","Value.Attributes.L01"},
{
{"Name1","Australia"}, {"Name2","Volkwagen"}
}
),
CellValue = #table
(
{"Cell.Value"},
{
{"1"}, {"5"}, {"6"}
}
),
ListAccumulate = List.Accumulate
(
{0..Table.RowCount(Source)-1},
CellValue,
(old,current)=>
Table.AddColumn(old, Source[Title.Name]{current}, each Source[Value.Attributes.L01]{current} )
)
in
ListAccumulate
Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy