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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Jtbonner1986
Helper I
Helper I

Count Non Matching Rows

Hi, 

 

Sorry for the basic question here:

I have 2 tables, a pricing table and a material table (joined by material ID). I want to understand where i have a record in my material table but do not have a price for it. I basically want to count the non matching rows in the pricing table when i plot my material table:

 

EG:

 

Material Table

 

MaterialProduct
1231
3451
6781

 

Pricing Table:

 

MaterialPrice
123£100
XXX£50

 

I want a measure to return a count of '2' when i select Product '1'

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Jtbonner1986 

 

Create a one-to-many single direciton relationship from Price to Material

danextian_0-1741183228097.png

Create this measure:

count = 
CALCULATE (
    COUNTROWS ( Material ),
    KEEPFILTERS ( ISBLANK ( 'Price'[Material] ) )
)

danextian_1-1741183310550.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

8 REPLIES 8
danextian
Super User
Super User

Hi @Jtbonner1986 

 

Create a one-to-many single direciton relationship from Price to Material

danextian_0-1741183228097.png

Create this measure:

count = 
CALCULATE (
    COUNTROWS ( Material ),
    KEEPFILTERS ( ISBLANK ( 'Price'[Material] ) )
)

danextian_1-1741183310550.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

I want to add a layer of complexity to this... So my price table can have multiple rows in it (for differing prices & dates) 

 

I want to essentially do the same (count the blank rows) however, due to the natrue of this structure it now returns '3'

 

new Price Table:

 

MaterialPriceDate
123£10001/01/2024
XXX£1001/01/2024
123£5002/01/2024

 

Hi @Jtbonner1986 

Break the relationship between the two tables and try this:

non matching materials = 
COUNTROWS (
    -- EXCEPT returns the set of values in 'Material[Material]' that are not in 'Price[Material]'
    EXCEPT ( VALUES ( Material[Material] ), VALUES ( 'Price'[Material] ) ) 
)

danextian_1-1741236185914.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

This seems to work, however i am always going to have a relationship with the 2 tables

bhanu_gautam
Super User
Super User

@Jtbonner1986 

Create a relationship between the Material Table and the Pricing Table using the Material column.

Create a measure in your Material Table to count the non-matching rows

DAX
NonMatchingCount =
CALCULATE(
COUNTROWS('Material Table'),
ISBLANK(RELATED('Pricing Table'[Price]))
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






this syntax is incorrect.. 

Azadsingh
Helper I
Helper I

Please share more information, I am not clear what you are expecting in result.

i want a single card visual displaying the number of materials which do not have a price. in this case material 345 and 678 do not have prices so i would want the result 2

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.