+ Reply to Thread
Results 1 to 6 of 6

Power Query Dynamic Merge Columns

  1. #1
    Registered User
    Join Date
    04-28-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2003, 07 & 10, 16
    Posts
    26

    Power Query Dynamic Merge Columns

    Hi -

    In the process of learning Power Query and M. I'm loading PDF's from our enterprise system and although the PDF layout is exactly the same for each data pull, sometimes the data comes over into Power Query different. Sometimes the PDF comes over in 13 columns, while other times it comes in 16 columns. I'm merging all the columns of the PDF into 1 column, but my code doesn't work if the source PDF has 16 columns. I've searched for several hours now and can't really find a good answer. Seems like what I've come across involves several steps and I can't believe that this is the easiest way. Below is the m code that I have for the 13 column file. I'm really looking for a line of code that says "merge all columns in the source PDF into 1".

    Anybody come across this and found a quick solution?
    Please Login or Register  to view this content.
    Thanks,
    GRC
    Last edited by grcaz; 06-02-2022 at 07:07 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Power Query Dynamic Merge Columns

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    04-28-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2003, 07 & 10, 16
    Posts
    26

    Re: Power Query Dynamic Merge Columns

    Thanks Alan -

    sorry, forgot about that.

    Regards,
    GRC

  4. #4
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: Power Query Dynamic Merge Columns

    Hi,

    Would it be possible to upload the 2 instances of pdf files with the 13 columns and the 16 columns?

    if the data is confidential please change the info to something else and give us a expected outcome to compare and alter the m language code sniped

    thanks
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  5. #5
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,381

    Re: Power Query Dynamic Merge Columns

    Here an example
    Attached Files Attached Files

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Power Query Dynamic Merge Columns

    I'm not sure what the attached file does to show the issue, but looking at the Mcode in the Original Post, for the line

    #"Merged Columns"

    it appears that you are only merging 13 columns. Why not change your line of Mcode to

    Merge your data into a New Column and add an if-then statement for 13 versus 16 columns. You can then delete the extraneous columns

+ 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. [SOLVED] Merge data in power query
    By Undo in forum Excel General
    Replies: 4
    Last Post: 08-19-2021, 05:42 AM
  2. [SOLVED] Merge Pro tip in Power Query
    By hudson andrew in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2021, 03:53 AM
  3. new entry in merge power query
    By rosscortb in forum Excel General
    Replies: 1
    Last Post: 04-24-2020, 05:02 AM
  4. Power query merge column
    By Eric Tsang in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-17-2020, 09:08 AM
  5. Power Query Merge Columns if Not Null
    By brent_milne in forum Excel General
    Replies: 1
    Last Post: 01-26-2020, 11:41 AM
  6. Replies: 1
    Last Post: 03-12-2019, 04:42 PM
  7. Merge Sheets Power Query
    By morerockin in forum Excel General
    Replies: 8
    Last Post: 04-11-2017, 08:17 AM

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