Russell Hauf
MrExcel MVP
- Joined
- Feb 10, 2002
- Messages
- 1,611
So I'm pretty new to M / Power Query, and I am trying to do something similar to this post
I have a function that does operations on a table and it works, we will call it TableOps1. I'm trying to write TableOps2 that calls TableOps1 while there are still Lists or Records in my table (I also have a function that returns the names of the fields with a particular type, called GetAllColumnsWithType)...TableOps2 is NOT working.
Here's what I've tried so far (and a few variations of this) - this iteration seems to just go into an infinite loop (no syntax errors or anything):
Any ideas what I'm doing wrong / suggestions?
Thanks in advance!
I have a function that does operations on a table and it works, we will call it TableOps1. I'm trying to write TableOps2 that calls TableOps1 while there are still Lists or Records in my table (I also have a function that returns the names of the fields with a particular type, called GetAllColumnsWithType)...TableOps2 is NOT working.
Here's what I've tried so far (and a few variations of this) - this iteration seems to just go into an infinite loop (no syntax errors or anything):
Code:
let
TableOps2 = (inTable as table) as table =>
let
tblCpy = Table.Buffer(inTable),
Loop =
List.Generate(
()=> [Table = tblCpy,
Counter = 1,
Continue = List.Count(GetAllColumnsWithType(tblCpy, type list)) + List.Count(GetAllColumnsWithType(tblCpy, type record)) > 0],
each [Continue],
each [Table = TableOps1(tblCpy),
Continue = [Counter] < 8 or (List.Count(GetAllColumnsWithType(Table, type list)) + List.Count(GetAllColumnsWithType(Table, type record)) > 0),
Counter = [Counter] + 1],
each [Table]),
TableWithData = if List.IsEmpty(Loop) then tblCpy else List.Last(Loop)
in
TableWithData
in
TableOps2
Thanks in advance!