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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
yoav20007
Helper II
Helper II

Can i do it in PQ?

PQ-1.PNG

1 ACCEPTED SOLUTION
ibarrau
Super User
Super User

Hi. Sure you can. You can do almost everything with Power Query. Let me copy the code and if you have doubts you can ask for a pbix with the example and the same code. I tried to use your column names for this. Think as Source the word "Origen". I'm sorry I hace my Power Bi in spannish. 

    #"Filas agrupadas" = Table.Group(Origen, {"Name"}, {{"ToTable", each _, type table [Columna1=text, Columna2=text]}}),
    #"Personalizada agregada" = Table.AddColumn(#"Filas agrupadas", "ToList", each Table.ToList(Table.SelectColumns([ToTable], "Product"))),
    #"Personalizada agregada1" = Table.AddColumn(#"Personalizada agregada", "ByCommas", each Text.Combine([ToList], ",")),
    #"Dividir columna por delimitador" = Table.SplitColumn(#"Personalizada agregada1", "ByCommas", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Product.1", "Product.2", "Product.3", "Product.4"}),
    #"Columnas quitadas" = Table.RemoveColumns(#"Dividir columna por delimitador",{"ToTable", "ToList"})

You have to group by, then convert that to list, join together by commas and finally split commas in columns.

Hope this help

 

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

View solution in original post

2 REPLIES 2
ibarrau
Super User
Super User

Hi. Sure you can. You can do almost everything with Power Query. Let me copy the code and if you have doubts you can ask for a pbix with the example and the same code. I tried to use your column names for this. Think as Source the word "Origen". I'm sorry I hace my Power Bi in spannish. 

    #"Filas agrupadas" = Table.Group(Origen, {"Name"}, {{"ToTable", each _, type table [Columna1=text, Columna2=text]}}),
    #"Personalizada agregada" = Table.AddColumn(#"Filas agrupadas", "ToList", each Table.ToList(Table.SelectColumns([ToTable], "Product"))),
    #"Personalizada agregada1" = Table.AddColumn(#"Personalizada agregada", "ByCommas", each Text.Combine([ToList], ",")),
    #"Dividir columna por delimitador" = Table.SplitColumn(#"Personalizada agregada1", "ByCommas", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Product.1", "Product.2", "Product.3", "Product.4"}),
    #"Columnas quitadas" = Table.RemoveColumns(#"Dividir columna por delimitador",{"ToTable", "ToList"})

You have to group by, then convert that to list, join together by commas and finally split commas in columns.

Hope this help

 

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Thanks for your time

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors