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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Child Parent Hierarchy with multiple parent - show part by choosing an element

Hello,

 

I have a table with child-parent hierarchy with multiple parent and I need to filter it if I choose a particular element.

Here is my table :

pathparentPathidElement
1 13
1|2114
1|2|31|215
1|2|41|216
1|5117
1|6118
7 14
7|8719
9 20
10 21
11|121122

Now, if I choose an element, I want to keep parents and children, espacially in the case where the element appeared multiple times.

Here is an exemple if I choose element 14:

pathparentPathidElement
1 13
1|2114
1|2|31|215
1|2|41|216
7 14
7|8719

It needs to work even if there is a parent of a parent or a child of a child.

 

Thank you !

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_1-1679032392106.png

Table2:

create with below dax formula

Table 2 = VALUES('Table'[idElement])

vbinbinyumsft_0-1679032376327.png

2. create a measure with below dax formula

Measure =
VAR _ie =
    SELECTEDVALUE ( 'Table 2'[idElement] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), 'Table'[idElement] = _ie )
VAR tmp1 =
    CALCULATETABLE ( VALUES ( 'Table'[path] ), tmp )
VAR tmp2 =
    CALCULATETABLE ( VALUES ( 'Table'[parentPath] ), tmp )
VAR cur_ie =
    SELECTEDVALUE ( 'Table'[idElement] )
VAR cur_path =
    SELECTEDVALUE ( 'Table'[path] )
VAR cur_ptpath =
    SELECTEDVALUE ( 'Table'[parentPath] )
RETURN
    SWITCH (
        TRUE (),
        cur_ie = _ie, 1,
        cur_path IN tmp2, 1,
        cur_ptpath IN tmp1, 1,
        ISBLANK ( _ie ), 1
    )

3. add a slicer visual with Table2 field, add a table visual with Table fields, add measure to table visual filter pane and apply it

Animation06.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_1-1679032392106.png

Table2:

create with below dax formula

Table 2 = VALUES('Table'[idElement])

vbinbinyumsft_0-1679032376327.png

2. create a measure with below dax formula

Measure =
VAR _ie =
    SELECTEDVALUE ( 'Table 2'[idElement] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), 'Table'[idElement] = _ie )
VAR tmp1 =
    CALCULATETABLE ( VALUES ( 'Table'[path] ), tmp )
VAR tmp2 =
    CALCULATETABLE ( VALUES ( 'Table'[parentPath] ), tmp )
VAR cur_ie =
    SELECTEDVALUE ( 'Table'[idElement] )
VAR cur_path =
    SELECTEDVALUE ( 'Table'[path] )
VAR cur_ptpath =
    SELECTEDVALUE ( 'Table'[parentPath] )
RETURN
    SWITCH (
        TRUE (),
        cur_ie = _ie, 1,
        cur_path IN tmp2, 1,
        cur_ptpath IN tmp1, 1,
        ISBLANK ( _ie ), 1
    )

3. add a slicer visual with Table2 field, add a table visual with Table fields, add measure to table visual filter pane and apply it

Animation06.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors