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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Loop within a loop

Hi, everyone.

 

I'm newer to Power BI, and I'm trying to mash 2 functions together to execute a loop within a loop.

  1. My first function, GetAllFolders, generates a table with 2 columns: FolderID and FolderName
  2. My second function, GetAllQueuesinFolder, generates a table with 3 columns: QueueName, OrganizationalUnitId, and ID.

What I need is for a table to be produced that takes each row of the table from GetAllFolders and loops through each row to GetAllQueuesInFolder for each folder. In the end, I want a table that has a row for each queue in all the folders. So, if each of my 4 folders has 2 queues, then I want a table with 5 columns (FolderID, FolderName, QueueName, OrganizationalUnit, and ID) and 8 rows, one for each queue.

 

Any ideas how to create this function?

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

=Table.FromRecords(List.TransformMany(Table.ToRecords(GetAllFolders(),each Table.ToRecords(GetAllQueuensinFolder([FolderName])),(x,y)=>x&y))

View solution in original post

3 REPLIES 3
wdx223_Daniel
Super User
Super User

=Table.FromRecords(List.TransformMany(Table.ToRecords(GetAllFolders(),each Table.ToRecords(GetAllQueuensinFolder([FolderName])),(x,y)=>x&y))

Anonymous
Not applicable

Thanks for your help.
I pasted your function in Power BI like so:

jmatuch_0-1702479507844.png

And clicked "Invoke" and got this error:

jmatuch_1-1702479548999.png

 

Any ideas? Thanks again.

 

EDIT:

I think I wasn't putting the function in the editor correctly. I entered it like this now, and I still got the same error as above.

jmatuch_0-1702479973854.png

 

 

 

Thanks so much for your help. I am just learning this language.

my code just a example, you need complete it in your real circumstance.

GetAllFolders() and GetAllQueuensinFolder() may have some arguements to fill.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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