Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
OneWithQuestion
Post Prodigy
Post Prodigy

Using composite keys: better to concatenate the two columns in Power Query or as DAX?

I have two tables that have no unique key to them.

 

I have to merge two columns together to get a unique composite key that I can use to join them on.

Is it more efficient for PBI if I do the creation of the new column in PowerQuery or after the data is loaded and do it in DAX as a calculated column there?

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @OneWithQuestion ,

 

Maybe Union() function can help achieve this:

See my 2 sample tables below:

Annotation 2020-07-24 105739.pngAnnotation 2020-07-24 105711.png

Then using below dax expression to create a new table with a unique key:

new table = UNION(DISTINCT('Table'[Category]),DISTINCT('Table 1'[Category]))

And you will get a new table as below:

Annotation 2020-07-24 105918.png

See attached for my sample .pbix file.Hope this is what you need.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @OneWithQuestion ,

 

Maybe Union() function can help achieve this:

See my 2 sample tables below:

Annotation 2020-07-24 105739.pngAnnotation 2020-07-24 105711.png

Then using below dax expression to create a new table with a unique key:

new table = UNION(DISTINCT('Table'[Category]),DISTINCT('Table 1'[Category]))

And you will get a new table as below:

Annotation 2020-07-24 105918.png

See attached for my sample .pbix file.Hope this is what you need.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Greg_Deckler
Super User
Super User

@OneWithQuestion - Probably Power Query but doubt it will matter that much unless you are talking tens of millions of rows.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.