Forum Discussion
Pikachu-Power
5 years agoImpactful Individual
UNION DISTINCT question
hi all,
i found following way to combine two distinct tables and use UNION like in SQL (without double entries):
TABLE_X =
UNION (
SUMMARIZE(Table1, Table1[A], Table1[B], Table1[C]),
SUMMARIZE(Table2, Table2[A], Table2[B], Table2[C])
)
TABLE_Y =
SUMMARIZE(Table_X, Table_X[A], Table_X[B], Table_X[C])
Is it possible to write that in one measure? a better dax formular is also welcome 🙂
- Anonymous5 years ago
Hi Pikachu-Power ,
You can write this DAX:
TABLE = Var _X= UNION ( SUMMARIZE(Table1, Table1[A], Table1[B], Table1[C]), SUMMARIZE(Table2, Table2[A], Table2[B], Table2[C]) ) Return SUMMARIZE(_X,[A], [B], [C])Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- mahoneypatMicrosoft Employee
You can try this expression
NewTable =
var TableX = UNION (SUMMARIZE(Table1, Table1[A], Table1[B], Table1[C]),SUMMARIZE(Table2, Table2[A], Table2[B], Table2[C]))ReturnSUMMARIZE(TableX, Table1[A], Table1[B], Table1[C])Pat- Pikachu-PowerImpactful IndividualThanks. Seems to work. But shouldnt we use somethink like:...ReturnSUMMARIZE(TableX, TableX[A], TableX[B], TableX[C])
- AnonymousNot applicable
Hi Pikachu-Power ,
You can write this DAX:
TABLE = Var _X= UNION ( SUMMARIZE(Table1, Table1[A], Table1[B], Table1[C]), SUMMARIZE(Table2, Table2[A], Table2[B], Table2[C]) ) Return SUMMARIZE(_X,[A], [B], [C])Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.