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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Akshaymanjunath
Frequent Visitor

How to find distinct count of an id in first table which is not present in the second table

consider 2 tables orders and sales having conection with each other and below are the table details

 

consider table 1 : orders

below are fields of orders table

which contains

id

name

order date

 

consider table 2 : sales

below are fields of sales table:

idsales

quantity

ship date

 

now find the distinct count of "id" in the orders table that is not present in the sales table using dax

 

note:

is the below formula correct

distinct count not in table = CALCULATE(DISTINCTCOUNT(orders[id]), NOT(orders[id] IN VALUES(sales[id])))

 

@MattAllington @xifeng_L @lbendlin 

2 ACCEPTED SOLUTIONS
vicky_
Super User
Super User

I would try something like the below:

distinct count not in table = COUNTROWS(EXCEPT(VALUES(orders[id]), VALUES(sales[id])))

 

View solution in original post

That's fine, but I think it might be better to change VALUES to ALL, so as to avoid the effects of some extraneous filtering.

 

distinct count not in table = COUNTROWS(EXCEPT(ALL(orders[id]), ALL(sales[id])))

 

View solution in original post

3 REPLIES 3
MattAllington
Community Champion
Community Champion

The type of relationship between the table matters. What is the cardinality and direction of filter propagation?  A screen should of the model view is normally easiest 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
vicky_
Super User
Super User

I would try something like the below:

distinct count not in table = COUNTROWS(EXCEPT(VALUES(orders[id]), VALUES(sales[id])))

 

That's fine, but I think it might be better to change VALUES to ALL, so as to avoid the effects of some extraneous filtering.

 

distinct count not in table = COUNTROWS(EXCEPT(ALL(orders[id]), ALL(sales[id])))

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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