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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MTOnet
Helper III
Helper III

Display Parent and All Child Records when Value from a Child Record is Selected

I am having difficulty with a problem that I am trying to solve.  I am trying to display the Parent and all Child records, when a value from one of the child records is selected from a filter, that is seperate from the data.

 

I have been able to display all child records when the selected value matches the parent record as well as the parent when a child record is selected, but I am having difficulty getting all the child records.

 

Here is my Data

IDParent IDTypeAssigned
1 Type1PersonA
2 Type1PersonB
3 Type1PersonC
41Type2PersonB
52Type2Person A
63Type2PersonD
72Type3PersonC
81Type3PersonB
93Type3PersonA

 

Desired Result - If PersonD is selected from the Filter, then display the following

IDParent IDTypeAssigned
3 Type1PersonC
63Type2PersonD
93Type3PersonA

 

I've tried taking the parent ID of a row and then creating a filtered table to see if the the selected Assigned value exists in that filterd table, but I can't seem to quite get the logic right.  Is there a different way I should approach this.  Thanks for any assistance.

1 ACCEPTED SOLUTION
MTOnet
Helper III
Helper III

So I solved my issue. and it was such an easy fix.  There was a filter being applied on my data, which resulted in me not getting what I wanted.  Once I added All(Table) to my filter, I got the results i was looking for.  For anybody else looking for this, here is my solution.

 

RelatedtoAssigned = 
var result = switch(max('Table'[Type]),
    "Type1",if(CONTAINS( Filter(all('Table'),'Table'[ParentID]=max('Table'[Id])),'Table'[Assigned],[SelectionAssignedTo]),1,0),
    "Type2",if(CONTAINS( Filter(all('Table'),'Table'[ParentID]=max('Table'[ParentID])),'Table'[Assigned],[SelectionAssignedTo]),1,0),
    "Type3",if(CONTAINS( Filter(all('Table'),'Table'[ParentID]=max('Table'[ParentID])),'Table'[Assigned],[SelectionAssignedTo]),1,0))
return
    result
    
Where [SelectionAssignedTo] is a measure that gets the value selected in the filter

View solution in original post

1 REPLY 1
MTOnet
Helper III
Helper III

So I solved my issue. and it was such an easy fix.  There was a filter being applied on my data, which resulted in me not getting what I wanted.  Once I added All(Table) to my filter, I got the results i was looking for.  For anybody else looking for this, here is my solution.

 

RelatedtoAssigned = 
var result = switch(max('Table'[Type]),
    "Type1",if(CONTAINS( Filter(all('Table'),'Table'[ParentID]=max('Table'[Id])),'Table'[Assigned],[SelectionAssignedTo]),1,0),
    "Type2",if(CONTAINS( Filter(all('Table'),'Table'[ParentID]=max('Table'[ParentID])),'Table'[Assigned],[SelectionAssignedTo]),1,0),
    "Type3",if(CONTAINS( Filter(all('Table'),'Table'[ParentID]=max('Table'[ParentID])),'Table'[Assigned],[SelectionAssignedTo]),1,0))
return
    result
    
Where [SelectionAssignedTo] is a measure that gets the value selected in the filter

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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