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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Measure for Primary Key ID not found in Foreign Key table

Hello,

 

I'm trying to filter a measure to only show the IDs that are not found in a related table. 

 

What I have currently:

 

Closed Won Opportunites without Request =
     CALCULATE([Count of Closed Won Opportunities], NOT(Opportunity[OPPORTUNTIY_ID] IN 'Sales Engineering Request'))
 
Any help is very appreciated!
1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1672990216582.png

vjianbolimsft_1-1672990227211.png

Please try:

Measure = IF(NOT( MAX('Main Table'[Primary Key ID]) in SELECTCOLUMNS(ALL('Related Table'),"ID",[ID])),1)

Apply it to the visual:

vjianbolimsft_2-1672990385985.png

If you need a table:

Table = EXCEPT(VALUES('Main Table'[Primary Key ID]),VALUES('Related Table'[ID]))

Output:

vjianbolimsft_3-1672990508454.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1672990216582.png

vjianbolimsft_1-1672990227211.png

Please try:

Measure = IF(NOT( MAX('Main Table'[Primary Key ID]) in SELECTCOLUMNS(ALL('Related Table'),"ID",[ID])),1)

Apply it to the visual:

vjianbolimsft_2-1672990385985.png

If you need a table:

Table = EXCEPT(VALUES('Main Table'[Primary Key ID]),VALUES('Related Table'[ID]))

Output:

vjianbolimsft_3-1672990508454.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

djurecicK2
Super User
Super User

Hi @Anonymous ,

 What is the result of the measure you've posted? You might need to change this section since I'm guessing that the ID field does not contain the text 'Sales Engineering Request'

NOT(Opportunity[OPPORTUNTIY_ID] IN 'Sales Engineering Request'

 

If the field you are looking for is a related table, you can get the value using RELATED:

https://learn.microsoft.com/en-us/dax/related-function-dax

https://dax.guide/related/

Please accept as solution if this answers the question- thanks!

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors