+ Reply to Thread
Results 1 to 4 of 4

Macro for Power Query? (adding column)

  1. #1
    Registered User
    Join Date
    03-15-2015
    Location
    Espaņa
    MS-Off Ver
    2013
    Posts
    80

    Macro for Power Query? (adding column)

    Hello there,

    I wonder if the following is possible. I have a file with over 14 million rows. It is a raw CSV file that can be easily handled using Power Query.

    However, I need to analyze some information that is only available by comparing some row cells to an independent file I have with the desired information to analyze. For example:

    Party Code Party
    001 A name
    002 Another
    001 A name
    152 Here
    132 Random


    And I need to analyze them depending on whether the party is X, Y or Z ... Information available in an independent file. It looks like this:

    Party Code Type
    001 coalition
    002 Other
    001 coalition
    152 alone
    132 other


    The expected result within the power query:

    Party Code Party Is coalition Others Is Party alone
    001 A name coalition
    002 Another Other
    001 A name coalition
    152 Here alone
    132 Random other

    That way I can easily filter them out by the type of Party.
    Therefore, I was wondering if there is any way to create a macro that adds new columns to the power query based on that independent file.
    Last edited by elbrujo; 11-14-2019 at 11:06 PM.

  2. #2
    Forum Contributor
    Join Date
    11-05-2019
    Location
    Tiki Island, TX
    MS-Off Ver
    Office 365
    Posts
    168

    Re: Macro for Power Query? (adding column)

    You can add columns to the power query pretty easily just by using the power query interface and merging the queries. Is there a reason you want to use a macro? Perhaps the source filename changes or something like that?

  3. #3
    Registered User
    Join Date
    03-15-2015
    Location
    Espaņa
    MS-Off Ver
    2013
    Posts
    80

    Re: Macro for Power Query? (adding column)

    Hi there.

    Indeed, I can easily add new columns. The problem is the data management for that column, as I require the cells to contain certain text depending on the rest of the row.
    I managed to get a VB code that modified the CSV files directly, adding new content depending on the row. For now, that's how I solved it.

    Kind regards.

  4. #4
    Forum Contributor
    Join Date
    11-05-2019
    Location
    Tiki Island, TX
    MS-Off Ver
    Office 365
    Posts
    168

    Re: Macro for Power Query? (adding column)

    You can still do it all in power query. See the attached workbook. Shown below is what you see in the advanced editor of the Merge1 query that accomplishes your goal without a macro. Just make the tables on File1 and File2 link to the data files.
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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] Power Pivot does not load new column added in Power query
    By ibuhary in forum Excel General
    Replies: 12
    Last Post: 02-19-2019, 03:53 AM
  2. [SOLVED] Adding manual data to a power query?
    By S7ewie in forum Excel General
    Replies: 20
    Last Post: 01-19-2019, 08:44 AM
  3. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  4. Adding Column in Power Query
    By fuerte in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-28-2018, 12:39 PM
  5. Adding Column in Power Query
    By fuerte in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2018, 11:15 AM
  6. Power Query and adding a column changing dates
    By ammartino44 in forum Excel General
    Replies: 0
    Last Post: 01-09-2018, 05:24 AM
  7. Adding data to the end of a table with Power Query
    By afila in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2016, 08:29 AM

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