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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

display all child hierarchy based on parent

Hi,

I have created hierarchy structure and I need to "display all the child" of parent hierarchy.

Diagram:

          1
         /   \
       2       3
      / |\      / \
    4 5 6    7   8
          /\        / \
       9 10    11 12

 

From the above diagram,

I need if I select parent "2" then it show 4,5,9,10 child below of "2"

If I select parent "3" then it should show 7,11,12 child below of "3".

If I select parent "6" then it show 9,10 child below of "6"

If I select parent "8" then it show 11,12 child below of "8".

 

Note: This should happen in dynamically.

 

Table structure:

 

ProjectkeyParentKeyPathlength
1 11
211|22
311|32
421|2|43
521|2|53
621|2|63
731|3|73
831|3|83
961|2|6|94
1061|2|6|104
1181|3|8|114
1281|3|8|124
1 ACCEPTED SOLUTION

@Anonymous

 

In that case we can add another condition as follows
Please see attached file as well

 

Measure =
VAR myparent =
    MIN ( Parents[ParentKey] )
VAR Condition1 =
    PATHCONTAINS ( SELECTEDVALUE ( Table1[Path] ), myparent )
VAR condition2 =
    SEARCH ( myparent, SELECTEDVALUE ( Table1[Path] ), 1, 0 )
        < SEARCH (
            SELECTEDVALUE ( Table1[Projectkey] ),
            SELECTEDVALUE ( Table1[Path] ),
            1,
            0
        )
VAR Condition3 =
    COUNTROWS (
        FILTER (
            ALL ( Table1 ),
            SEARCH ( SELECTEDVALUE ( Table1[Projectkey] ), Table1[Path], 1, 0 )
        )
    ) = 1
RETURN
    IF ( AND ( AND ( Condition1, condition2 ), Condition3 ), 1 )

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Please see if this approach helps

 

See the file attached as well

 

Assuming your TableName is Table1.
First create a calculated table from modelling tab. This will be used as slicer to select parent

 

Parents =
FILTER ( DISTINCT ( Table1[ParentKey] ), [ParentKey] <> BLANK () )

Now we can write a MEASURE to be used as a visual filter

 

Measure =
VAR myparent =
    MIN ( Parents[ParentKey] )
VAR Condition1 =
    PATHCONTAINS ( SELECTEDVALUE ( Table1[Path] ), myparent )
VAR condition3 =
    SEARCH ( myparent, SELECTEDVALUE ( Table1[Path] ), 1, 0 )
        < SEARCH (
            SELECTEDVALUE ( Table1[Projectkey] ),
            SELECTEDVALUE ( Table1[Path] ),
            1,
            0
        )
RETURN
    IF ( AND ( Condition1, condition3 ), 1 )

Regards
Zubair

Please try my custom visuals

@Anonymous

 

parentchild.png


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

@Zubair_Muhammad

 

Thanks for your reply, I want only child not include parents. if select parent "3" its should show only  child like 7,11,12 not 8 because "8" is parent key.

@Anonymous

 

In that case we can add another condition as follows
Please see attached file as well

 

Measure =
VAR myparent =
    MIN ( Parents[ParentKey] )
VAR Condition1 =
    PATHCONTAINS ( SELECTEDVALUE ( Table1[Path] ), myparent )
VAR condition2 =
    SEARCH ( myparent, SELECTEDVALUE ( Table1[Path] ), 1, 0 )
        < SEARCH (
            SELECTEDVALUE ( Table1[Projectkey] ),
            SELECTEDVALUE ( Table1[Path] ),
            1,
            0
        )
VAR Condition3 =
    COUNTROWS (
        FILTER (
            ALL ( Table1 ),
            SEARCH ( SELECTEDVALUE ( Table1[Projectkey] ), Table1[Path], 1, 0 )
        )
    ) = 1
RETURN
    IF ( AND ( AND ( Condition1, condition2 ), Condition3 ), 1 )

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.