Dynamically merge columns in PQ

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
703
Office Version
  1. 365
Platform
  1. Windows
i watched and tried to copy form different youtube videos
it is not working although video worked perfectly. my list can grow form anywhere between 500-1000 columns
what am i doing wrong?
Power Query:
let
    Source = Excel.Workbook(File.Contents("M:\all\VENDORS WITH ADDRESSES 2.xlsx"), null, true),
    vendors_with_addresses_2_Table = Source{[Item="vendors_with_addresses_2",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(vendors_with_addresses_2_Table,{{"Vendor", type text}, {"Status", type text}, {"Other ID", Int64.Type}, {"Address Field 1", type text}, {"Address Field 2", type text}, {"City", type text}, {"State", type text}, {"Zip Code", Int64.Type}, {"Phone", type text}, {"Email", type text},{"database id", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Status] = "A")),
    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Email"}),
    #"Filtered Rows1" = Table.SelectRows(#"Removed Other Columns", each ([Email] <> null and [Email] <> "")),
    #"Removed Duplicates" = Table.Distinct(#"Filtered Rows1"),
    #"Sorted Rows" = Table.Sort(#"Removed Duplicates",{{"Email", Order.Ascending}}),
    #"Transposed Table" = Table.Transpose(#"Sorted Rows"),
    #"Removed Other Columns1" = Table.SelectColumns(#"Transposed Table",{"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12", "Column13", "Column14", "Column15", "Column16", "Column17", "Column18", "Column19", "Column20", "Column21", "Column22", "Column23", "Column24", "Column25", "Column26", "Column27", "Column28", "Column29", "Column30", "Column31", "Column32", "Column33", "Column34", "Column35", "Column36", "Column37", "Column38", "Column39", "Column40", "Column41", "Column42", "Column43", "Column44", "Column45", "Column46", "Column47", "Column48", "Column49", "Column50", "Column51", "Column52", "Column53", "Column54", "Column55", "Column56", "Column57", "Column58", "Column59", "Column60", "Column61", "Column62", "Column63", "Column64", "Column65", "Column66", "Column67", "Column68", "Column69", "Column70", "Column71", "Column72", "Column73", "Column74", "Column75", "Column76", "Column77", "Column78", "Column79", "Column80", "Column81", "Column82", "Column83", "Column84", "Column85", "Column86", "Column87", "Column88", "Column89", "Column90", "Column91", "Column92", "Column93", "Column94", "Column95", "Column96", "Column97", "Column98", "Column99", "Column100", "Column101", "Column102", "Column103", "Column104", "Column105", "Column106", "Column107", "Column108", "Column109", "Column110", "Column111", "Column112", "Column113", "Column114", "Column115", "Column116", "Column117", "Column118", "Column119", "Column120", "Column121", "Column122", "Column123", "Column124", "Column125", "Column126", "Column127", "Column128", "Column129", "Column130", "Column131", "Column132", "Column133", "Column134", "Column135", "Column136", "Column137", "Column138", "Column139", "Column140", "Column141", "Column142", "Column143", "Column144", "Column145", "Column146", "Column147", "Column148", "Column149", "Column150", "Column151", "Column152", "Column153", "Column154", "Column155", "Column156", "Column157", "Column158", "Column159", "Column160", "Column161", "Column162", "Column163", "Column164", "Column165", "Column166", "Column167", "Column168", "Column169", "Column170", "Column171", "Column172", "Column173", "Column174", "Column175", "Column176", "Column177", "Column178", "Column179", "Column180", "Column181", "Column182", "Column183", "Column184", "Column185", "Column186", "Column187", "Column188", "Column189", "Column190", "Column191", "Column192", "Column193", "Column194", "Column195", "Column196", "Column197", "Column198", "Column199", "Column200", "Column201", "Column202", "Column203", "Column204", "Column205", "Column206", "Column207", "Column208", "Column209", "Column210", "Column211", "Column212", "Column213", "Column214", "Column215", "Column216", "Column217", "Column218", "Column219", "Column220", "Column221", "Column222", "Column223", "Column224", "Column225", "Column226", "Column227", "Column228", "Column229", "Column230", "Column231", "Column232", "Column233", "Column234", "Column235", "Column236", "Column237", "Column238", "Column239", "Column240", "Column241", "Column242", "Column243", "Column244", "Column245", "Column246", "Column247", "Column248", "Column249", "Column250", "Column251", "Column252", "Column253", "Column254", "Column255", "Column256", "Column257", "Column258", "Column259", "Column260", "Column261", "Column262", "Column263", "Column264", "Column265", "Column266", "Column267", "Column268", "Column269", "Column270", "Column271", "Column272", "Column273", "Column274", "Column275", "Column276", "Column277", "Column278", "Column279", "Column280", "Column281", "Column282", "Column283", "Column284", "Column285", "Column286", "Column287", "Column288", "Column289", "Column290", "Column291", "Column292", "Column293", "Column294", "Column295", "Column296", "Column297", "Column298", "Column299", "Column300", "Column301", "Column302", "Column303", "Column304", "Column305", "Column306", "Column307", "Column308", "Column309", "Column310", "Column311", "Column312", "Column313", "Column314", "Column315", "Column316", "Column317", "Column318", "Column319", "Column320", "Column321", "Column322", "Column323", "Column324", "Column325", "Column326", "Column327", "Column328", "Column329", "Column330", "Column331", "Column332", "Column333", "Column334", "Column335", "Column336", "Column337", "Column338", "Column339", "Column340", "Column341", "Column342", "Column343", "Column344", "Column345", "Column346", "Column347", "Column348", "Column349", "Column350", "Column351", "Column352", "Column353", "Column354", "Column355", "Column356", "Column357", "Column358", "Column359", "Column360", "Column361", "Column362", "Column363", "Column364", "Column365", "Column366", "Column367", "Column368", "Column369", "Column370", "Column371", "Column372", "Column373", "Column374", "Column375", "Column376", "Column377", "Column378", "Column379", "Column380", "Column381", "Column382", "Column383", "Column384", "Column385", "Column386", "Column387", "Column388", "Column389", "Column390", "Column391", "Column392", "Column393", "Column394", "Column395", "Column396", "Column397", "Column398", "Column399", "Column400", "Column401", "Column402", "Column403", "Column404", "Column405", "Column406", "Column407", "Column408", "Column409", "Column410", "Column411", "Column412", "Column413", "Column414", "Column415", "Column416", "Column417", "Column418", "Column419", "Column420", "Column421", "Column422", "Column423", "Column424", "Column425", "Column426", "Column427", "Column428", "Column429", "Column430", "Column431", "Column432", "Column433", "Column434", "Column435", "Column436", "Column437", "Column438", "Column439", "Column440", "Column441", "Column442", "Column443", "Column444", "Column445", "Column446", "Column447", "Column448", "Column449", "Column450", "Column451", "Column452", "Column453", "Column454", "Column455", "Column456", "Column457", "Column458", "Column459", "Column460", "Column461", "Column462", "Column463", "Column464", "Column465", "Column466", "Column467", "Column468", "Column469", "Column470", "Column471", "Column472", "Column473", "Column474", "Column475", "Column476", "Column477", "Column478", "Column479", "Column480", "Column481", "Column482", "Column483", "Column484", "Column485", "Column486", "Column487", "Column488", "Column489", "Column490", "Column491", "Column492", "Column493", "Column494", "Column495", "Column496", "Column497", "Column498", "Column499", "Column500", "Column501", "Column502", "Column503", "Column504", "Column505", "Column506", "Column507", "Column508", "Column509", "Column510", "Column511", "Column512", "Column513", "Column514", "Column515", "Column516", "Column517", "Column518", "Column519", "Column520", "Column521", "Column522", "Column523", "Column524", "Column525", "Column526", "Column527", "Column528", "Column529", "Column530", "Column531", "Column532", "Column533", "Column534", "Column535", "Column536", "Column537", "Column538", "Column539", "Column540", "Column541", "Column542", "Column543", "Column544", "Column545", "Column546", "Column547", "Column548", "Column549", "Column550", "Column551", "Column552", "Column553", "Column554", "Column555", "Column556", "Column557", "Column558", "Column559", "Column560", "Column561", "Column562", "Column563", "Column564", "Column565", "Column566", "Column567", "Column568", "Column569", "Column570", "Column571", "Column572", "Column573", "Column574", "Column575", "Column576", "Column577", "Column578", "Column579", "Column580", "Column581", "Column582", "Column583", "Column584", "Column585", "Column586", "Column587", "Column588", "Column589", "Column590", "Column591", "Column592", "Column593", "Column594", "Column595", "Column596", "Column597", "Column598", "Column599", "Column600", "Column601", "Column602", "Column603", "Column604", "Column605", "Column606", "Column607", "Column608", "Column609", "Column610", "Column611", "Column612"}),
    Result = Table.AddColumn (#"Removed Other Columns1", "Email Merged", each
            let
                CreateList = Record.ToList(_), 
                ConvertToText = List.Transform(CreateList, each Text.From(_) ),
                Concatenate = Text.Combine( ConvertToText, "; " )
            in
                Concatenate
    )
in
    Result
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top