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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! 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 Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors