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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
dutchgarma
Regular Visitor

converting a table to a list of lists


Hi, Im trying to convert a table (manually defined, in another query) to a list of lists but I have trouble understanding the Table.ToList function. The main thing that I dont understand is how to define the combiner function that turns the rows into lists.

Example:

id name
1 dirk
2 jeff

and I would want this to be something like

{
{"1", "dirk"},
{"2", "jeff"}
}

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Table.ToList is not the right command for your request. You need to use Table.ToRows instead.

 

Table.ToList would return a list, but the elements wouldn't be lists, but one text field instead. This will be created combining all columns of your table/current row. The parameter you choose in the Combiner-function will be used as a separator there.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

6 REPLIES 6
ImkeF
Super User
Super User

Table.ToList is not the right command for your request. You need to use Table.ToRows instead.

 

Table.ToList would return a list, but the elements wouldn't be lists, but one text field instead. This will be created combining all columns of your table/current row. The parameter you choose in the Combiner-function will be used as a separator there.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hello Imke,

 

Can you help me with this?

I got this formula:

 

Changed Text = Text.Combine(List.ReplaceMatchingItems([Custom],Table.ToRows[Liste])," ")

 

Only [Liste] is in another query (the one with the table with words a want to change), so the formula is not working. Do you know the solution?

 

gr. Henri

 

Wrong shape of brackets 🙂

 

Changed Text = Text.Combine(List.ReplaceMatchingItems([Custom],Table.ToRows(Liste))," ")

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi Imke,

 

Your code is the first step to the solution.

 

I made a testfile: test wordchange.pbix

 

So maybe you van watch at it to see what i'm doing wrong?

 

gr. Henri

Check out this file: https://1drv.ms/u/s!Av_aAl3fXRbehawXGP7MNV4hnLP8tg

 

& be aware that M is case sensitive.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

WOW!!

 

Big thanks.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.