Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
When I join 2 tables, I am receiving duplicate values, because in same cases for the same entry I have 2 values. I would like to know, at the end of joining, if I can make distinct, and get only one.
Join =
VAR A =
SELECTCOLUMNS (
TableA,
"An", RELATED(Advertisers[An]),
"Key", FORMAT(TableA[Key],"string")
)
VAR B =
SELECTCOLUMNS (
TableB,
"idAn", TableB[IdAnunciante],
"NameAn", TableB[NomeAnunciante],
"Key", FORMAT(TableB[KeyMkt],"string")
)
VAR Result =
NATURALINNERJOIN( B, A )
VAR Dist = SUMMARIZE(Result, [IdAn] , [NameAn], [An] )
RETURN
Dist
Result (In same cases I get 2 entrys):
IdAn | NameAn | An |
1153 | XPTO | TesteXPTO |
1153 | XPTO | XPTO |
What I want (I just want one entry, regardless of which entry is):
IdAn | NameAn | An |
1153 | XPTO | XPTO |
or
IdAn | NameAn | An |
1153 | XPTO | TesteXPTO |
I need to do this with DAX, because tableA as more than 100M entrys
Solved! Go to Solution.
Hi @flaviocarvalho ,
Has your problem been solved?
If not, do you mind sharing your .pbix file? Or show me the sample data of TableA, TableB and Advertisers.
Or you can use table visual to get the table.
Or create another table.
'Sheet2' table is your 'join' table.
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @flaviocarvalho ,
Has your problem been solved?
If not, do you mind sharing your .pbix file? Or show me the sample data of TableA, TableB and Advertisers.
Or you can use table visual to get the table.
Or create another table.
'Sheet2' table is your 'join' table.
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Creating another table solved the problem. The problem was that I need a Many-to-One connection to another table.
Hi @flaviocarvalho ,
Try to use MAXX() function.
Join =
VAR A =
SELECTCOLUMNS (
TableA,
"An", RELATED(Advertisers[An]),
"Key", FORMAT(TableA[Key],"string")
)
VAR B =
SELECTCOLUMNS (
TableB,
"idAn", TableB[IdAnunciante],
"NameAn", TableB[NomeAnunciante],
"Key", FORMAT(TableB[KeyMkt],"string")
)
VAR Result =
NATURALINNERJOIN( B, A )
VAR Dist = SUMMARIZE(Result, [IdAn] , [NameAn], "An", MAXX(Result, [An]) )
RETURN
Dist
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-lionel-msft ,
I think we are close. My original table without MAX is:
IdAn | NameAn | An |
1153 | XPTO | TestXPTO |
1153 | XPTO | XPTO |
1164 | Yee | Yee |
2154 | Whiskey | Whiskey |
Now the result is the following:
IdAn | NameAn | An |
1153 | XPTO | Whiskey |
1164 | Yee | Whiskey |
2154 | Whiskey | Whiskey |
But I need the Max / Min "An" of each ID, like this:
( I tried Maxx(values(Result[IdAn)) but cannot find the table )
IdAn | NameAn | An |
1153 | XPTO | XPTO |
1164 | Yee | Yee |
2154 | Whiskey | Whiskey |
@flaviocarvalho , See if this can help
At the end of your code
VAR Dist = SUMMARIZE(Result, [IdAn] , [NameAn],"An" , max([An]) ) // or use min
RETURN
Dist
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |