Forum Discussion

anna93's avatar
anna93
Regular Visitor
6 years ago
Solved

Combine / Append tables based on condition

Hello all, 

 

I am trying to combine / append two tables with the same columns only if condition is met. For example, from table 1 below I would to like to get the rows in which Project Number = PO number and copy to the second table, what is the best to complete this in PowerQuery? I believe I would need an IF condition in the query but I am pretty new on this and I don't know how to write it. 

 

Thank you!

 

Project NumberFiscal YearFiscal PeriodCost ElementPO numberPo lineAmount
1510342020830306001352131
15103420202340099541532154
1510342020234009955456141
151034202023400995654646
1510342020234009958134164
151034202023400995954648
1510342020434009952542514
151034202043400995102132154
151034201975100151034110531
15103420191151001510341851
151034201912510015103411534
1510342020151001510341515
151034202025100151034121
1510342020751001510341541545

5 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion
    Just create a column:

    = if [Project Number] = [Po number] then 1 else 0

    Then just filter out the 0's
    • anna93's avatar
      anna93
      Regular Visitor

      Hi Greg - Appreciate your help on this but unfortuantely the below wouldn't work as I my question is around transferring rows of data from one table to another table if condition is met. 

    • anna93's avatar
      anna93
      Regular Visitor

      Hi Maggie, 

       

      Yes both tables have same column names, it just have different data. 

  • v-juanli-msft's avatar
    v-juanli-msft
    Community Support

    Hi anna93 

    Create a new query and uncheck "enable load",

    Then in Table2, append query1

     

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.