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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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