Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
aukev
Helper III
Helper III

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
Solution Specialist
Solution Specialist

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.