Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi.
I need help please.
Need to join 2 tables in DAX, so code goes like this:
FirstTable = ADDCOLUMNS(
"Team","Team1",
"Sales", sum(InitialTable[Sales],
"Revenue", sum(InitialTable[Revenue])
SecondTable = ADDCOLUMNS(
"Team","Team1",
"Sales", 100,
"Revenue", 20)
return union(FirstTable,SecondTable)
So for example First table is:
Sales Revenue
Team1 500 300
But then it is overwrites SecondTable inputs and I get at the end:
Sales Revenue
Team1 500 300
Team2 500 300
It supposed to be:
Sales Revenue
Team1 500 300
Team2 100 20
Somehow measures from FirstTable overwrite values from SecondTable.
I need not to mix them.
What I am doing wrong?
Thank you
HI @Yaro
Please try
=
VAR T1 =
ROW (
"Team", "Team1",
"Sales", SUM ( InitialTable[Sales] ),
"Revenue", SUM ( InitialTable[Revenue] )
)
VAR T2 =
ROW ( "Team", "Team1", "Sales", 100, "Revenue", 20 )
RETURN
UNION ( T1, T2 )
hi @Tameer
thank you for your reply
Row will return only one row of data?
The example I have given is just to showcase the situation
in fact I need to group those tables by many teams
I think the answer is to Union tables on row level and then summarize the final output
hi @Yaro
UNION is not supposed to overwrite values. Could you paste some sample data?
hi @FreemanZ
I have InitialTable for Team1 which looks like this:
Member | Sales | Revenue |
Member1 | 300 | 200 |
Member2 | 200 | 100 |
So I write code summarizing that table.
var FirstTable=ADDCOLUMN ("Team","Team1","Sales",sum(InitialTable[Sales]),sum(InitialTable[Revenue]))
then I want to add Team2 just with dummy numbers
var SecondTable={("Team2",0,0)}
return union(FirstTable,SecondTable) gives me that result
Team | Sales | Revenue |
Team1 | 500 | 300 |
Team2 | 500 | 300 |
Thank you.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
16 | |
8 | |
7 | |
7 | |
6 |
User | Count |
---|---|
23 | |
11 | |
10 | |
9 | |
8 |