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

Help editing code to merge list with table

Hello all!

 

I brought in my data and did a few transformations up to #filtered Rows. After that step, there is code to create a list to merge paired rows (bad data that I had to fix).

 

The problem I am having now is with the #"Combine with Original Table" step. I need it to place the newly create list in the same position in the table as "Personnal Category" (which is one of the promoted headers) while retaining all the previous transformations promoted headers, change type and filtered row.

 

Please help!?

 

Thanks so much!!

 

let
    Source = Folder.Files("C:\Users\O81465\Downloads\OneDrive_2023-01-20\Mexico Ruben Dario - Control de Acceso\Mexico R&D - Control de Acceso\R&D 2022"),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
    #"Expanded Transform File" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9"}, {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9"}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Expanded Transform File", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Personnal Category", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Personnal Category] = "PRESTADOR DE " or [Personnal Category] = "SERVICIOS EXTERNO" or [Personnal Category] = "SERVICIOS INTERNO")),
    #"Even Rows" = List.Alternate(#"Filtered Rows"[Personnal Category],1,1,1),
    #"Odd Rows" = List.Alternate(#"Filtered Rows"[Personnal Category],1,1,0),
    #"Combine Lists" = List.Transform(List.Zip({#"Even Rows",#"Odd Rows"}), each Text.Combine(_," ")),
    #"Alternate with nulls" = List.Combine(List.Zip({#"Combine Lists", List.Repeat({null}, List.Count(#"Combine Lists"))})),
    #"Combine with Original Table" = Table.FromColumns({#"Alternate with nulls"} & Table.ToColumns(Table.RemoveColumns(#"Changed Type",{"Personnal Category"})), Table.ColumnNames(#"Changed Type"))
in
    #"Combine with Original Table"

 

0 REPLIES 0

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.