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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Nakeele
Regular Visitor

Select all children from Parent based on 1 child selected through a slicer

Hi all,

 

I've "Table A" where I have columns "Parents" and "Children" and Table B with "Children".

 

I have a report where a slicer based on a child from Table B drives all charts. But I'd like to display all children from the child's parent.

Unfortunately, it only displays the actual parent and child but not all the children.

 

Any thoughts?

 

Thank you!

 

N

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Nakeele 

According to your statement, I think your requirement is to get all children under the same parent based on the child you selected in slicer. Here I suggest you to create an unrelated child table to create the slicer.

Then create a measure, add this measure into filter field in your visual and set it to show items if the value equal to 1.

Try this code:

 

Filter = 
VAR _SelectChildren =
    SELECTEDVALUE ( 'Table B'[Children] )
VAR _Parent =
    CALCULATETABLE (
        VALUES ( 'Table A'[Parent] ),
        FILTER ( ALL ( 'Table A' ), 'Table A'[Children] = _SelectChildren )
    )
RETURN
    IF (
        ISFILTERED ( 'Table B'[Children] ),
        IF ( MAX ( 'Table A'[Parent] ) IN _Parent, 1, 0 ),
        1
    )

 

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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
tsumit07
Frequent Visitor

Also i need to use this inside a slicer.

What would be the best approach in this case?

tsumit07
Frequent Visitor

Hi Nico , 

 

How could we use same measure for text values in Child column?

i am working on a similar issue where in my table Parent and child contains text values.

Really appreciate your help .

 

Thank you

S

Anonymous
Not applicable

Hi @Nakeele 

According to your statement, I think your requirement is to get all children under the same parent based on the child you selected in slicer. Here I suggest you to create an unrelated child table to create the slicer.

Then create a measure, add this measure into filter field in your visual and set it to show items if the value equal to 1.

Try this code:

 

Filter = 
VAR _SelectChildren =
    SELECTEDVALUE ( 'Table B'[Children] )
VAR _Parent =
    CALCULATETABLE (
        VALUES ( 'Table A'[Parent] ),
        FILTER ( ALL ( 'Table A' ), 'Table A'[Children] = _SelectChildren )
    )
RETURN
    IF (
        ISFILTERED ( 'Table B'[Children] ),
        IF ( MAX ( 'Table A'[Parent] ) IN _Parent, 1, 0 ),
        1
    )

 

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

 

Works like a charm! Thanks!

amitchandak
Super User
Super User

@Nakeele , Prefer to create an independent child table for slicer

 

a measure like

 

Meausre  =

var _parent = summarize(filter(TableA, TableA[Child] in selectedvalue(Child[Child]) ), TableA[parent])

var _child = summarize(filter(TableA, TableA[parent] in _parent ), TableA[Child])

return

counrows(filter(TableB, TableB[Child] in _child))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Actually, I get a message in the countrows: "The number of arguments is invalid. Function CONTAINSROW must have a value for each column in the table expression."

 

Countrows(filter('Table B','Table B'[child] in _child))

 

Trying to see what causes it but it's expecting something else somehow.

Sorry if the question is lame.

 

Thank you for your help!

 

N

Hi @amitchandak 

 

Thanks so much for the help. Juste a quick question, when you say "selectedvalue(Child[Child])", what are you referring to exactly?

 

Thanks again!

 

N

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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