cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Measure - Parent child relationship

Hi,

 

I need to create a measure to Parent name using id=parentid join.

 

Table

idNameParent_id
101A 
102B101
103C101
104D103
105E103

 

 

Create a Measure "Parent Name".

 

idNameParent Name
101A 
102BA
103CA
104DC
105EC

 

Can't modify the Dataset due to company policy.

 

Is there a way to calculate the measure?

 

 

1 ACCEPTED SOLUTION

Ahh, I had done mine as a measure.  Because you said you couldn't modify the data set I thought you couldn't add a column.  I have updated the calculated column to work and also added in the measure in the attached file.

 

View solution in original post

6 REPLIES 6
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Give this a try.

Parent Name =
VAR RowParent =
    SELECTEDVALUE ( 'Your Table'[Parent_id] )
RETURN
    IF (
        ISBLANK ( RowParent ),
        "n/a",
        LOOKUPVALUE ( 'Your Table'[Name], 'Your Table'[id], RowParent )
    )

 parentname.jpg

Strange. I tried your solution, why mine is showing n/a?

 

2019_08_15_09_08_33_Untitled_Power_BI_Desktop.png

In your table, is ID a number and Parent ID text?

Both are text.

I changed to number and still the same.

Here  is the pbix

Ahh, I had done mine as a measure.  Because you said you couldn't modify the data set I thought you couldn't add a column.  I have updated the calculated column to work and also added in the measure in the attached file.

 

oops, I am not the one who posted. I gaveit a try because I want to learn.

And you did not fail me, I really did learn something new from you today.

 

Thank you @jdbuchanan71 ! You are awesome!!

Helpful resources

Announcements
Exciting changes

Power BI Community Changes

Check out the changes to the Power BI Community announced at Build.

May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Top Solution Authors