+ Reply to Thread
Results 1 to 3 of 3

Power Query append tables side by side

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    771

    Power Query append tables side by side

    Hi,
    I have managed to append / join two tables side by side but wondered if there was a better more efficient / dynamic way of doing it as
    I had to transpose / transpose back etc but I can't find anything about this online ?
    my method as indivdual steps; was ;

    let
        Source = Excel.CurrentWorkbook(),
    
        Start = Table.RemoveColumns(Source,{"Name"}) [Content],
    
        Demote = List.Transform(  Start, each Table.DemoteHeaders(_) ),
    
        Custom1 = List.Transform(  Demote, each Table.Transpose(_) ),
    
        Custom2 = Table.Combine(  Custom1 ),
    
        Custom3 = Table.Transpose(  Custom2 ),
    
        Custom4 = Table.PromoteHeaders(  Custom3 )
    in
        Custom4
    I have attached the above and would be interested in any suggestions on tackling this ,

    Richard
    Attached Files Attached Files

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: Power Query append tables side by side

    I suspect the reason you can't find it online is that you would have to have some terrible data sets to need to merge them without a common field. To that end, I'd just add one:

    let
        Source = Excel.CurrentWorkbook(),
        AddIndices = Table.ReplaceValue(Source,each [Content],each Table.AddIndexColumn([Content],"Index",1),Replacer.ReplaceValue,{"Content"}),
        Out = List.Accumulate(AddIndices[Content],null, (s, c)=>if s = null then c else Table.Join(s, "Index", c, "Index"))
    in
        Table.RemoveColumns(Out, {"Index"})
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    771

    Re: Power Query append tables side by side

    I also found this a bit shorter than original method

    = let headers  =  Table.ColumnNames(  TableA & TableB ) , 
    
    tolists = Table.ToColumns( TableA) & Table.ToColumns( TableB) , 
    
    totable =  Table.FromColumns ( tolists , headers ) 
    
    in totable
    Richard.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Power Query append tables and sort columns
    By viewotst in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-09-2022, 10:30 AM
  2. [SOLVED] Power Query - Append and merge tables
    By DystopiaRelic in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-13-2021, 02:42 PM
  3. Power Query - Append 2 tables from different workbooks
    By elleb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2020, 05:17 PM
  4. Replies: 0
    Last Post: 05-31-2018, 08:49 AM
  5. [SOLVED] How to create a month and Year-to-date column side by side in pivot table
    By Dewdrop in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-13-2017, 02:25 AM
  6. Power Query - how to append tables
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-25-2015, 04:55 AM
  7. Replies: 0
    Last Post: 04-19-2009, 10:53 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1