Forum Discussion

MaryamSe's avatar
MaryamSe
Frequent Visitor
2 years ago
Solved

Creating a reference table from other tables using power quesry

Hi,  I have 4 tables that they include differet columns with different names. However, all include a date column, and an ID. I want to create a new table in power query that I can use a refernce tab...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, MaryamSe 

    Thank you very much for your reply. If you want to append the previously selected column, you can use M code similar to the following

     

    let
        Source1 = Sheet6,
        Source2 = Sheet1,
        Source3 = Sheet7,
        FirstTable = Table.SelectColumns(Source1, {"id","date"}),
        SecondTable = Table.SelectColumns(Source2, {"id","date"}),
        ThirdTable = Table.SelectColumns(Source3,{"id","date"}),
        Combined = Table.Combine({FirstTable, SecondTable,ThirdTable})
    
    in
        Combined

    First of all, the source1, source2, and source3 equal signs are followed by the query names on the left side of PowerQuery, as shown in the following figure:

    Then use the Table.SelectColumns function to select the id and date columns in these tables. The selected columns are appended at the end. 

    Here are some steps:

    First, right-click on the blank space on the left side of the mouse to create a blank query

    Open the advanced editor and paste the M code above:

    You need to replace the name after the source1-3 equals sign above with your actual query name. You can also add more sources, similar to the ones above.

     

     

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.