cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
pisca
Frequent Visitor

Concatenate Parent and Child Value

Hi, 

 

How to create New Column like this table?

topic_idtopic_pidtopicNew Column
10HardwareHardware
21ComputerHardware / Computer
31PrinterHardware / Printer
40Office365Office365
52WordOffice365 / Word
62ExcelOffice365 / Excel
72Power PointOffice365 / Power Point

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@pisca , Try a new column like

New column =
var _max = maxx(filter(Table, Table[topic_pid]=0 && [topic_id] <earlier([topic_id])),[topic_id])
return
if([topic_pid]<>0 , maxx(filter(Table, Table[topic_pid]=0 && [topic_id] =_max),[topic]) &"/" & [topic],[topic])

View solution in original post

Mariusz
Community Champion
Community Champion

Hi @pisca 

 

You can use this DAX column pattern for the below result.

New Column = 
VAR __getParentChildHierarchy = PATH( 'Table'[topic_id], 'Table'[topic_pid] )
VAR __selectFirstParent = PATHITEM( __getParentChildHierarchy, 1, INTEGER ) 
VAR __lookupTopicByID = 
    LOOKUPVALUE( 
        'Table'[topic], 
        'Table'[topic_id], __selectFirstParent 
    )
VAR __topic = 'Table'[topic]
RETURN 
IF( 
    NOT __lookupTopicByID == __topic, 
    __lookupTopicByID & " / " & __topic,
    __topic
)

 

 

image.png

 

This is if the topic_pid for office = 4, not 2 and you replace 0 with null so PATH() function works correctly

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

4 REPLIES 4
Mariusz
Community Champion
Community Champion

Hi @pisca 

 

You can use this DAX column pattern for the below result.

New Column = 
VAR __getParentChildHierarchy = PATH( 'Table'[topic_id], 'Table'[topic_pid] )
VAR __selectFirstParent = PATHITEM( __getParentChildHierarchy, 1, INTEGER ) 
VAR __lookupTopicByID = 
    LOOKUPVALUE( 
        'Table'[topic], 
        'Table'[topic_id], __selectFirstParent 
    )
VAR __topic = 'Table'[topic]
RETURN 
IF( 
    NOT __lookupTopicByID == __topic, 
    __lookupTopicByID & " / " & __topic,
    __topic
)

 

 

image.png

 

This is if the topic_pid for office = 4, not 2 and you replace 0 with null so PATH() function works correctly

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

pisca
Frequent Visitor

Awesome, Thanks a lot..

amitchandak
Super User
Super User

@pisca , Try a new column like

New column =
var _max = maxx(filter(Table, Table[topic_pid]=0 && [topic_id] <earlier([topic_id])),[topic_id])
return
if([topic_pid]<>0 , maxx(filter(Table, Table[topic_pid]=0 && [topic_id] =_max),[topic]) &"/" & [topic],[topic])

Awesome, Thanks a lot..

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors