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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Tim1984
New Member

Help with relationships

Hi All,

 

Still early learning this, however I am having issues with relationships

What I am trying to work out is how to show the description for multi columns ( only seem to be getting one) 

table 1 - Client

table 2 - master 

 

Client Table

NameGenderDescription
John Smith00010004
Claire0002Null
Bob00010003

 

Master Table

IDDescription
0001Male
0002Female
0003

Australia

0004

New Zealand

 

Power BI dash ( how i want it to show) 

 

ClientGenderCountry of birth
John smithMaleNew Zealand
ClaireFemale 
BobMaleAustralia

 

 

Currently it will show the gender but not the country of birth ( as just shows the ID not the Desciption 

 

I currently have a one to many relationship setup for Master table (ID) to Client table (Gender)

 

help please as I have about 15 fields that have IDs that all live in the Master table with a description.

2 ACCEPTED SOLUTIONS
Irwan
Memorable Member
Memorable Member

hello @Tim1984 

 

you have unique ID in Master table and you are fine with measure, then you can do this without building relationship between those two table.

Irwan_0-1731377318558.png

1. create Gender measure with following DAX

Gender Measure = 
var _ID = SELECTEDVALUE('Table 1'[Gender])
Return
MAXX(
    FILTER(
        'Table 2',
        'Table 2'[ID]=_ID
    ),
    'Table 2'[Description]
)
2. create Country of Birth measure with following DAX.
Country of Birth = 
var _ID = SELECTEDVALUE('Table 1'[Description])
Return
MAXX(
    FILTER(
        'Table 2',
        'Table 2'[ID]=_ID
    ),
    'Table 2'[Description]
)
basically, the idea is finding the same ID between those two table then return the result in a column you want.
 
Hope this will help.
Thank you.
 

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

One of ways to achieve this is to use USERELATIONSHIP DAX function in measures.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1731387067226.png

 

 

Jihwan_Kim_0-1731387017453.png

 

 

USERELATIONSHIP function (DAX) - DAX | Microsoft Learn

 

Gender: = 
IF (
    HASONEVALUE ( Client[Name] ),
    MAXX ( SUMMARIZE ( Client, Master[Description] ), Master[Description] )
)

 

Country of birth: = 
CALCULATE ( [Gender:], USERELATIONSHIP ( Master[ID], Client[Description] ) )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

3 REPLIES 3
v-zhouwen-msft
Community Support
Community Support

Hi all,thanks for the quick reply, I'll add more.

Hi @Tim1984 ,

Use the following DAX expression to create a measure

Measure = 
VAR _description = SELECTEDVALUE(Client[Description])
RETURN LOOKUPVALUE('Master'[Description],Master[ID],_description)

Turn on the 'Show item with no data' option

vzhouwenmsft_0-1731397373892.png

Best Regards,
Wenbin Zhou

 

Jihwan_Kim
Super User
Super User

Hi,

One of ways to achieve this is to use USERELATIONSHIP DAX function in measures.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1731387067226.png

 

 

Jihwan_Kim_0-1731387017453.png

 

 

USERELATIONSHIP function (DAX) - DAX | Microsoft Learn

 

Gender: = 
IF (
    HASONEVALUE ( Client[Name] ),
    MAXX ( SUMMARIZE ( Client, Master[Description] ), Master[Description] )
)

 

Country of birth: = 
CALCULATE ( [Gender:], USERELATIONSHIP ( Master[ID], Client[Description] ) )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Irwan
Memorable Member
Memorable Member

hello @Tim1984 

 

you have unique ID in Master table and you are fine with measure, then you can do this without building relationship between those two table.

Irwan_0-1731377318558.png

1. create Gender measure with following DAX

Gender Measure = 
var _ID = SELECTEDVALUE('Table 1'[Gender])
Return
MAXX(
    FILTER(
        'Table 2',
        'Table 2'[ID]=_ID
    ),
    'Table 2'[Description]
)
2. create Country of Birth measure with following DAX.
Country of Birth = 
var _ID = SELECTEDVALUE('Table 1'[Description])
Return
MAXX(
    FILTER(
        'Table 2',
        'Table 2'[ID]=_ID
    ),
    'Table 2'[Description]
)
basically, the idea is finding the same ID between those two table then return the result in a column you want.
 
Hope this will help.
Thank you.
 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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