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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
twitchingdog
New Member

Power BI Query: Identify Parent record with qualifying Child records

Hi All - Looking for some assistance with Query or filter

 

Issue: I have a child TABLE A with a Direct relationship to PROJECT table. I want to filter TABLE A to ONLY show projects that have NO child records in TABLE A that have a value in Status. 

 

Example:

TABLE A

 

IDProjectIDStatus
1Anull
2Anull
3Anull
4BYellow
5Bn/a
6BRed
7Cnull
8Cnull
9Cnull
10D

Green

11D

null

12Dnull
   

 

Expected Results after FILTER:

 

ProjectID
A
C

 

Thanks for assistance

MB

4 REPLIES 4
artemus
Microsoft Employee
Microsoft Employee

let
    Source = <Your Data>,
    #"Grouped Rows" = Table.Group(Source, {"SourceNamespace"}, {{"Rows", each _, Value.Type(Source)}}),
    Custom1 = Table.SelectRows(#"Grouped Rows", each Table.SelectRows([Rows], each [ID} <> null){0}? = null),
    #"Removed Columns" = Table.RemoveColumns(Custom1,{"ID"}),
    Custom2 = if Table.RowCount(#"Removed Columns") = 0 then Table.RemoveRows(Source, 0) else Table.ExpandTableColumn(#"Removed Columns", "Rows", Table.ColumnNames(#"Removed Columns"[Rows]{0}))
in
    Custom2

 

Not sure what this has to do with a direct relationship though

thanks for info, I will try this out. 

 

I mention the ProjectID, because ultimately thatis what will join to my Project table to limit the # of child records reported on. ID is just the main table GUID, which is not necessary. It only was showing the respective table structure

 

 

 

Anonymous
Not applicable

Hi @twitchingdog ,

 

Using Table.Group and List.NonNullCOunt:

#"Grouped Rows" = Table.Group(Source, {"ProjectID"}, {{"Count", (t as table)=>List.NonNullCount(t[Status]), type number}}),
    #"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Count] = 0))

You are interested in rows that have zero NonNullCount.

 

Kind regards,

JB

twitchingdog
New Member

I think I figured this out:

 

1. Added a Custom column with If statement to ADD 0 for nulls and 1 for not null

= Table.AddColumn(#"Removed Other Columns", "Custom", each if [cxp_status] = null then 0 else 1)

 

2. Added a Group By on ProjectID and SUM of Custom Column added to Count column

= Table.Group(#"Added Custom", {"PROJECTID},{{"Count", each List.Sum([Custom]), type number}})

 

3. FLITERED on Count = 0

= Table.SelectRows(#"Grouped Rows", each ([PROJECTID] <> null) and ([Count] = 0))

 

Im left with 2 columns PROJECTID and Count. I can then filter the on Count = 0 which should give me all projects that have all related child records with status = NULL

 

sound right?

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.