Forum Discussion
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 Number | Fiscal Year | Fiscal Period | Cost Element | PO number | Po line | Amount |
| 151034 | 2020 | 8 | 3030 | 600 | 1 | 352131 |
| 151034 | 2020 | 2 | 3400 | 995 | 4 | 1532154 |
| 151034 | 2020 | 2 | 3400 | 995 | 5 | 456141 |
| 151034 | 2020 | 2 | 3400 | 995 | 6 | 54646 |
| 151034 | 2020 | 2 | 3400 | 995 | 8 | 134164 |
| 151034 | 2020 | 2 | 3400 | 995 | 9 | 54648 |
| 151034 | 2020 | 4 | 3400 | 995 | 2 | 542514 |
| 151034 | 2020 | 4 | 3400 | 995 | 10 | 2132154 |
| 151034 | 2019 | 7 | 5100 | 151034 | 1 | 10531 |
| 151034 | 2019 | 11 | 5100 | 151034 | 1 | 851 |
| 151034 | 2019 | 12 | 5100 | 151034 | 1 | 1534 |
| 151034 | 2020 | 1 | 5100 | 151034 | 1 | 515 |
| 151034 | 2020 | 2 | 5100 | 151034 | 1 | 21 |
| 151034 | 2020 | 7 | 5100 | 151034 | 1 | 541545 |
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.
5 Replies
- Greg_DecklerCommunity ChampionJust create a column:
= if [Project Number] = [Po number] then 1 else 0
Then just filter out the 0's- anna93Regular 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.
- v-juanli-msftCommunity Support
- anna93Regular Visitor
Hi Maggie,
Yes both tables have same column names, it just have different data.
- v-juanli-msftCommunity 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.