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
BlueTiger
Helper I
Helper I

Concatenate values in distant related table

I need to create a new column in the Clients table below which has the Staff manager's first name appended to the clients display name.

 

i.e. (Joe) ABC Company Ltd

 

Staff table is related to Relationship 1:* table by their StaffID for manager/partner/team.

Relationship table is related to the Clients table by ClientID 1:1.

 

I know how to use the concatenate command, but how do I reference the other table? When I use RELATED() it only allows me to see the Relationship table.

 

I know I could merge Relationship and Clients table, but I am avoiding that at the moment due to external issues.

 

PBI_Example.PNG

 

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @BlueTiger ,

Try this:

ManagerFirstName =
CALCULATE (
    CALCULATE ( VALUES ( Staff[First Name] ), Relationship ),
    USERELATIONSHIP ( Staff[StaffID], Relationship[Manager_StaffID] ),
    ALL ( Staff )
)

manager.PNG

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Nathaniel_C
Super User
Super User

Hi @BlueTiger ,
If I understand correctly, as you are going from the 1 to * you will probably need to use the RELATEDTABLE().
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I can't seem to reference the Column [First Name] when I do that. I am using CALCULATEDTABLE instead of RELATEDTABLE as I need to specify the relationship to use and RELATEDTABLE is just a short hand version of CALCULATEDTABLE.

 

 

Staff with Client Name = "(" & 
    CALCULATETABLE(
        Staff, 
        USERELATIONSHIP(
            Staff[StaffID],
            Relationship[Manager_StaffID]
        )
    )[First Name]
    & ") " & Clients[Display Name]

 

 

[First Name] is greyed out so it obviously isn't expecting me to specify the column there, but I am not sure why? It gives the error:

 
The syntax for '[First Name]' is incorrect. (DAX("(" & CALCULATETABLE( Staff, USERELATIONSHIP( Staff[StaffID], Relationship[Manager_StaffID] ) )[First Name] & ") " & Clients[Display Name])).
 
Icey
Community Support
Community Support

Hi @BlueTiger ,

If you don't mind, please share me a dummy PBIX file without real data and sensitive information.

 

Best Regards,

Icey

Thank you.

 

I have created an example pbix file below with random generated data. This is a snippet of a larger data model I am working on.

 

https://www.dropbox.com/s/6irl43g5wyrselg/Forum_HelpWithRELATEDTABLE.pbix?dl=1

 

FYI In my first post I accidentally put the 1:* relationships the wrong way round from Staff to Relationship. I didn't notice until I started entering data for the example file.

Icey
Community Support
Community Support

Hi @BlueTiger ,

Try this:

ManagerFirstName =
CALCULATE (
    CALCULATE ( VALUES ( Staff[First Name] ), Relationship ),
    USERELATIONSHIP ( Staff[StaffID], Relationship[Manager_StaffID] ),
    ALL ( Staff )
)

manager.PNG

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.