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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Sum rows in parent table with no related rows in child table

Hi all,

 

I have a strange situation/model where the header has some sales ID records and amounts which have no corresponding lines in the child/many side. I need to sum all the values from the header where there are no matching lines. This is a one to many relationship between header and lines.

 

Example:

Sales Header (parent)

Sales Key                Sales Amount

1                                   500

2                                   300

3                                   100

4                                   200

 

Sales Lines

Sales Key  Line#    

1                  1           

1                  2       

2                  1

 

What I'd need is the sum amount from the header rows for Sales Key 3 and 4 in the above example, which would return 300. If we did a left outer join it would be the null rows.

 

Essentially I need to CALCULATE(SUM(SalesHeader[Amount]), FILTER(SalesHeader, SalesHeader[Sales Key]

NOT IN (SalesLines[Sales Key])

 

Obviosuly the above is incorrect as I'm not sure how to express NOT IN [list of values in related table] by using DAX. Any help is wonderful!

1 ACCEPTED SOLUTION

Then use VALUES(SalesLines[Sales Key]) to create a table of values for it to use.

View solution in original post

4 REPLIES 4
Cmcmahan
Resident Rockstar
Resident Rockstar

NOT is available in DAX though. The syntax would look like this:

 

 CALCULATE(SUM(SalesHeader[Amount]), FILTER(SalesHeader, NOT(SalesHeader[Sales Key] IN SalesLines[Sales Key])))

 

 

Anonymous
Not applicable

This doesn't seem to work, unfortunately. 

 

After the IN statement, I cannot specify a column name, it's looking for a measure or table for some reason.

Then use VALUES(SalesLines[Sales Key]) to create a table of values for it to use.

Anonymous
Not applicable

Ah, of course. Worked like a charm, thank you!

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.