cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
aaumond
Frequent Visitor

Expand column containing list of records

Hello,

 

I'm trying to expand a column which contains list of records on each cell in Power Query (for  example "Type de prestation" column) :

table with list of records.png 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Each record of lists is organized as follow (self, value and id) :

 2018-05-26 10_45_52-Sans titre - Éditeur Power Query.pngrecord.png

 

The idea would be to concatenate the values ​​"value" contained in each record of the list for each cell, delimiting them with semicolons.

 

For example, for the third row of the table, the celle "Type de prestation" would contain "PMO;Architecture".

 

I don't know if I'm clear... Have you ever done that? If yes, how?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Hi Anthony,

That's good news.

To catch errors in general, you can use try/otherwise.

 

In this case, this should work:

 

= Table.TransformColumns(#"Développer Type de prestation",
{{"Phase projet", each try Combiner.CombineTextByDelimiter(";")(List.Transform( _ , each [value]))
otherwise null, type text}})

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

3 REPLIES 3
OwenAuger
Super User
Super User

Hi @aaumond

 

You should create a new step with code like this.

PreviousStep should refer to the previous step in your existing query.

This is how the code would look in the advanced editor. If you enter in the formula bar by clicking fx, then leave out the step name CombineValueFromRecords.

 

CombineValueFromRecords =
  Table.TransformColumns(
    PreviousStep,
    {
      {
        "Type de prestation", 
        each Combiner.CombineTextByDelimiter(";")(
	  List.Transform( _, each [value] )
        ),
	type text
      }
    }
  )

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Hi @OwenAuger

 

Thank you so much for the solution! It works.

 

Just a small detail: when a cell is empty, an error is displayed because it can not convert the null value to a list. How can I avoid this kind of error?

 

2018-05-27 09_33_07-issues - Éditeur Power Query.png

 

Regards,

Anthony

Hi Anthony,

That's good news.

To catch errors in general, you can use try/otherwise.

 

In this case, this should work:

 

= Table.TransformColumns(#"Développer Type de prestation",
{{"Phase projet", each try Combiner.CombineTextByDelimiter(";")(List.Transform( _ , each [value]))
otherwise null, type text}})

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors