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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ClarkMitchell
Regular Visitor

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 @ClarkMitchell ,

 

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 @ClarkMitchell ,

 

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 @ClarkMitchell ,

 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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors