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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Concatenate columns where column name is dynamic

I am trying to solve the problem of having joins between tables being dynamic.

To do this my thinking is that the join would be based on a column called uniquID but that column itself will be the result of a DAX formula.

 

The DAX formula needs to do a look up on another table to find out what are the fields that make up the unique ID and then go back to the main table, find those columns, and do a concatenation to come up with the uniqueID.

 

Is this possible?

 

Update:

 

Sample data below. I want to create the UniqueID column using DAX, The DAX needs to do a look up to a setttings table to determine which fields it should concaternate. There are two ways I could think of, of laying out the setttings table.

 

Main Table

 

ABCDUniqueID
1231CD11231D1
1231CD21231D2
4562CD34562D3
4562CD14562D1

 

Settings Table

TableUniqueID fields
MainTableA
MainTableB
MainTable

D

 

 

Alternative settings table

TableUniqueFIeld1UniqueFIeld2UniqueFIeld3UniqueFIeld4UniqueFIeld5
MainTableABD  
3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

Based on my test, you could try this way as below:

Step1:

In Edit Queries, Add an index column for main table and then duplicate the main table.

Step2:

Select column A, B, C, D column Then unpivot it.

6.JPG

Step3:

Merge it with the settings table by Attribute column

7.JPG

Step4:

Expand the table and filter null value

8.JPG

Step5:

Close&Apply

Then create the relationship between main table and dup main table

9.JPG

Step6:

Use this formula to add a calculate column

UniqueID = CONCATENATEX(RELATEDTABLE('Dup Main table'),'Dup Main table'[Value],,'Dup Main table'[Attribute])

Result:

 

11.JPG

 

here is pbxi file, please try it.

 

 

Best Regards,

Lin

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks - I finally got round to reviewing this solution, I think it might work but the duiplication of the main table is not ideal, especialyl if the main table is rather large. Wil see if I can find any better solution else will awrd this the points.

Greg_Deckler
Super User
Super User

Maybe. Sample/example data would really help here. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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