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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Nicho248
Helper III
Helper III

Filter based on whats not in another table

Hello - Trying to write basic DAX formula. Must be doing something wrong. 

 

I have two tables. One table, Product, has all the part numbers. I have setup a relationship to another table, UoM. UoM has less part numbers in it. I'd like to know which part numbers are missing in UoM table, but are in Product table.

 

The relationship is setup as one to many (Product to UoM). Sometimes UoM has the part number in there more than once.

 

How do I do this? Here is example code I have tried that fails.

 

Missing UOM = 

Calculate (

COUNT( 'Product'[Product ID]),

FILTER('Product','Product'[Product ID] <> RELATED('UoM'[Product ID])))

 

Thanks

Nick

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

If you want to keep the 1:* relationship, use COUNTROWS(RELATEDTABLE()) in a calculated column in Products.  Otherwise, inactivate the relationship and use EXCEPT.

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

If you want to keep the 1:* relationship, use COUNTROWS(RELATEDTABLE()) in a calculated column in Products.  Otherwise, inactivate the relationship and use EXCEPT.

thank you. this worked great.

Wilson_
Memorable Member
Memorable Member

Hey Nicho,

 

Try something like this:

Missing UOM =
COUNTROWS (
    EXCEPT (
        VALUES ( 'Product'[Product ID] ),
        VALUES ( 'UOM'[Product ID] )
    )
)


----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

 

P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.

Wilson - I was not aware of EXCEPT and I will use this in the future. I marked the other recommendation as the solution because it helped filter a table visualization to identify which parts were actually missing. Unforunately with only your recommendation the table was providing non-sensical answers, however the measure on its own was working correctly. Thank you for your tip!

Nicho,

 

No worries, sometimes solutions work or not depending on the context in which they are used. It looks like you were looking for a calculated column and not a measure based on the other comment, whereas I shared a measure.

 

Glad you were able to get to a solution. 🙂

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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