cancel
Showing results for
Did you mean:
Frequent Visitor

one to many relationship count records that are not in the second table

Hi community experts, I have two tables, T1 and T2 with a relatinship one-to-many. Something like this

Table 1

 ID Attribute 1 0.5 2 1 3 1 4 0.8 5 0.8

Table 2

 ID Field2 1 1 1 3 3 5 5

Now, my relationship is based on the ID field. I also have a measure that sums the Attribute in Table 1.

How can I use this measure saying something like: Calculate(sum(Table1[Attribute]); Table2[ID] = blank()) which does not work.

I'd like to calculate that measures, to see how much the sum would be for the records that do not have any correspondent in Table2.

Any idea?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support

Re: one to many relationship count records that are not in the second table

Hi @emanuele ,

You can use expect function to compare and extract nonexistent records from two tables:

```Measure =
VAR _list =
EXCEPT ( VALUES ( Table1[ID] ), VALUES ( Table2[ID] ) )
RETURN
CALCULATE (
SUM ( Table[Attribute] ),
FILTER ( ALLSELECTED ( Table1 ), [ID] IN _list )
)
```

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI
Frequent Visitor

Re: one to many relationship count records that are not in the second table

Thanks, it helps!

2 REPLIES 2
Community Support

Re: one to many relationship count records that are not in the second table

Hi @emanuele ,

You can use expect function to compare and extract nonexistent records from two tables:

```Measure =
VAR _list =
EXCEPT ( VALUES ( Table1[ID] ), VALUES ( Table2[ID] ) )
RETURN
CALCULATE (
SUM ( Table[Attribute] ),
FILTER ( ALLSELECTED ( Table1 ), [ID] IN _list )
)
```

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI
Frequent Visitor

Re: one to many relationship count records that are not in the second table

Thanks, it helps!

Announcements

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors