Forum Discussion
Combine two table with conditons
I need combine two tables but with condition
Now i use
Append = Table.Combine( {Table1, Table2} ),
Tables structure is:
Table1
Code | Name
1130 | Product1
1140 | Produc3
Table2
Code | Name
1130 | Product1
1140 | Produc5
excpected result, but only on setted Codes for exmaple only if code =1140 and Name from T1 <> name from Table2
TableCombined
Code | Name
1130 | Product1
1140 | Produc3
1140 | Produc5
or
TableCombined
Code | Name
1130 | Product1
1140_t1 | Produc3
1140_t2 | Produc5
- Anonymous6 years ago
HI Analitika,
You can split these operations into multiple steps:
Merged=Table.Combine( {Table1, Table2} ),//merge #"Remove duplicate" = Table.Combine({Table.SelectRows(Merged,each [Code]<>1140 ),Table.Distinct(Table.SelectRows(Merged,each [Code]=1140 ))})//remove duplicate of specific records and merge wth others recordsRegards,
Xiaoxin Sheng
5 Replies
- amitchandakSuper User
Analitika , Append in power query and delete duplicate
https://radacad.com/append-vs-merge-in-power-bi-and-power-query
https://radacad.com/remove-duplicate-doesnt-work-in-power-query-for-power-bi-here-is-the-solution
https://backtosql.wordpress.com/2019/04/19/the-easy-way-to-duplicate-tables-in-power-bi/
Or Union in Dax
https://docs.microsoft.com/en-us/dax/union-function-dax
https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/
- Pragati11Super User
Hi Analitika ,
Rather than doing the combine in Power BI, you can use UNION function in DAX to combine these 2 tables with your additional filters.
Check the following thread on how you can use UNION with filters:
https://community.powerbi.com/t5/Desktop/Union-based-on-filter/td-p/691594
Thanks,
Pragati
- AnonymousNot applicable
Hi Analitika,
You can simply package your formula with 'Table.Distinct' function to prevent the duplicate records merged.
Append = Table.Distinct(Table.Combine( {Table1, Table2} ))Regards,
Xiaoxin Sheng
- AnalitikaPost Prodigy
I need to leave some duplicates
- AnonymousNot applicable
HI Analitika,
You can split these operations into multiple steps:
Merged=Table.Combine( {Table1, Table2} ),//merge #"Remove duplicate" = Table.Combine({Table.SelectRows(Merged,each [Code]<>1140 ),Table.Distinct(Table.SelectRows(Merged,each [Code]=1140 ))})//remove duplicate of specific records and merge wth others recordsRegards,
Xiaoxin Sheng