cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
aukev Regular Visitor
Regular Visitor

Combining a number of nested lists in a loop

What I want to achieve is this:

 

 newTable = Table.FromList(Pagination, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
 column= Table.ExpandRecordColumn(newTable, "Column1", {"WebCall"}, {"Column1.WebCall"}),   
 newList = column[Column1.WebCall],
Results= newList{0} & newList{1} & newList{2} & newList{3},

#"Converted to Table" = Record.ToTable(Results),
#"Expanded Value" = Table.ExpandRecordColumn(#"Converted to Table", "Value", {"entity_id", "created_at"}, {"Value.entity_id", "Value.created_at"})

But the problem is that the number of rows in newList  is unknown. In most cases it would be 100s of rows and the amount can differer so the above won't suffice.

 

So what I`m trying to figure out is how to do the following:

 

listCount = List.Count(newList),

 

And then something like a for each loop to add each row to the list as long as the Counter is lower then listCount.

 

i.e.

 

combinedList  = combinedList & newlist{Counter}

Counter +1

 

Is there a way to do this or are there any other methods of achieving the same?

 

Note that newList is a List with Records

 

 

 

2 REPLIES 2
Aron_Moore Established Member
Established Member

Re: Combining a number of nested lists in a loop

aukev Regular Visitor
Regular Visitor

Re: Combining a number of nested lists in a loop

Hi @Aron_Moore  I  tried that but that actually gives me a different result then when I combine them.

 

What I came up with is this:

 

 

 combinedList= List.Generate(()=>
[
Counter2 = 0,
combinedList = newList{0}
], //initial

each [Counter2] < List.Count(newList), //condition

each [
combinedList = [combinedList] & newList{Counter2},
Counter2 = [Counter2]+1
]
)

But that gives me a different result then using this

 

 

 

combinedList= newList{0} & newList{1} & newList{2} & newList{3}

 

See these screenshots:

 

Combining them manually:

 

manual.jpg

 

Using List.Generate

 

generatelist.jpg