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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Shamank77
New Member

want to create a column that meets your requirements

As shown in the attachment, there are three columns: name, parent_name and serial number column ID. Now I want to create a new column parent_id.

The number in the serial number column is automatically displayed based on the relationship between the NAME column and the PARENT_NAME column. For the expected result, see the attachment.

So don't know how the DAX text that creates such a column should be written in PowerBi

 

nameparent_nameidparent_id      
AH18      
BH28      
CH38      
DG47      
EC53      
FG67      
GE75      
H 8       
          
1 ACCEPTED SOLUTION

Hi, @Shamank77

According to your description, You want to show [parent_id] corresponding to [parent_name] according to the relationship between [name] and [id]. Right?

 

Here are the steps you can follow :

(1)This is my test data:

vyueyunzhmsft_2-1662434942556.png

 

(2)We can create a calculated column: “parent_id”:

parent_id =
VAR _table =
    SELECTCOLUMNS ( 'Table', "Name", [name], "id", [id] )
RETURN
    MAXX ( FILTER ( _table, [name] = EARLIER ( 'Table'[parent_name] ) ), [id] )

 

 

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_3-1662434979348.png

 

Best Regards,

Aniya Zhang

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

7 REPLIES 7
tamerj1
Super User
Super User

Hi @Shamank77 

You may also try

parent_id =
CALCULATE (
    SELECTEDVALUE ( TableName[id] ),
    TREATAS ( VALUES ( TableName[parent_name] ), TableName[name] )
)

Hi @tamerj1 

 

Thanks for your suggestion 😊

I tried to make the DAX as :

parent_id =
CALCULATE (
    SELECTEDVALUE ( TableName[id] ),
    TREATAS ( VALUES ( TableName[parent_name] ), TableName[name] )
)

 but the result became 

nameparent_nameidparent_id sampleparent_id
AH18 
BH28 
CH383
DG47 
EC535
FG67 
GE757
H 8 8

 

@Shamank77 

Please try

parent_id =
CALCULATE (
    SELECTEDVALUE ( TableName[id] ),
    TREATAS ( VALUES ( TableName[parent_name] ), TableName[name] ),
    REMOVEFILTERS ( TableName )
)
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached file.

It is for creating a new column.

 

Jihwan_Kim_0-1662433291295.png

 

 

Parend_id CC = 
LOOKUPVALUE('Table'[id],'Table'[name],'Table'[parent_name])

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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi, @Shamank77

According to your description, You want to show [parent_id] corresponding to [parent_name] according to the relationship between [name] and [id]. Right?

 

Here are the steps you can follow :

(1)This is my test data:

vyueyunzhmsft_2-1662434942556.png

 

(2)We can create a calculated column: “parent_id”:

parent_id =
VAR _table =
    SELECTCOLUMNS ( 'Table', "Name", [name], "id", [id] )
RETURN
    MAXX ( FILTER ( _table, [name] = EARLIER ( 'Table'[parent_name] ) ), [id] )

 

 

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_3-1662434979348.png

 

Best Regards,

Aniya Zhang

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

Hi ,Miss Zhang

Thanks for your suggestion~

The result is up to the mustard exactly

Yes,it works!Thank you very much indeed😄

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.