Forum Discussion
Append tables: remove rows in first table if value appears in second table
- 5 years ago
Hi kbuckvol ,
Just use the following dax to create a new table could more elegant way to do this,and get the final want you want!
base data:
Table1:
Table2:
Dax about create new table:
Table = VAR TABLE11 = CALCULATETABLE ( Table1, EXCEPT ( VALUES ( Table1[Item] ), VALUES ( Table2[Item] ) ) ) VAR TABLE12 = ADDCOLUMNS ( TABLE11, "Table", "Table1" ) VAR table22 = ADDCOLUMNS ( Table2, "Table", "Table2" ) VAR TABLEall = UNION ( TABLE12, Table22 ) RETURN TABLEallFinal result:
Wish it is helpful for you!
Best Regards
Lucien
Hi kbuckvol ,
Just use the following dax to create a new table could more elegant way to do this,and get the final want you want!
base data:
Table1:
Table2:
Dax about create new table:
Table =
VAR TABLE11 =
CALCULATETABLE (
Table1,
EXCEPT ( VALUES ( Table1[Item] ), VALUES ( Table2[Item] ) )
)
VAR TABLE12 =
ADDCOLUMNS ( TABLE11, "Table", "Table1" )
VAR table22 =
ADDCOLUMNS ( Table2, "Table", "Table2" )
VAR TABLEall =
UNION ( TABLE12, Table22 )
RETURN
TABLEall
Final result:
Wish it is helpful for you!
Best Regards
Lucien
Holy guacamole, this is perfect! Just what I was hoping for 🙂
One thing to note for those of you that might have this same question, I actually had a lot more columns in my tables and found out the UNION function requires the fields of both tables to be in the same order. Of course, both my tables had the fields in differing orders but this post that describes the SELECTCOLUMNS function to solve that problem.