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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
lakshmanan
Frequent Visitor

How to get Unmatched Row Count between related tables with different filters on each table.

Hi , 
I am new to PowerBI . Need help to write DAX query to get Unmatched counts .
Table 1:

lakshmanan_0-1665559470610.png

CustomerIDApplied Discount on ProductProductDiscountData from Date
1123Computers-10%Computers10%10/1/2022
1123Computers-20%Computers20%10/1/2022
43123Mobile-5%Mobile5%10/1/2022
45434Clothing-2%Clothing2%10/1/2022
43123Mobile-15%Mobile15%10/1/2022
2345Sports Item - 20%Sports Item20%10/1/2022
4546Fashion - 2%Fashion2%10/1/2022
1243Misc-24%Misc24%10/1/2022
1123Computers-25%Computers25%10/4/2022
45434Clothing-3%Clothing3%10/4/2022
43123Mobile-25%Mobile25%10/4/2022
5475Health-23%Health23%10/4/2022
4546Fashion - 4%Fashion4%10/4/2022
45432Mobile - 23%Mobile23%10/4/2022
3413Sports Item - 10%Sports Item10%10/4/2022
3425Health-32%Health32%10/4/2022
23213Mobile-6%Mobile6%10/4/2022
2545Health-43%Health43%10/4/2022
2346Misc-23%Misc23%10/4/2022

Table 2:

lakshmanan_0-1665566828778.png

 


Two Tables are related on "Applied Discount on Product"
Applied Discount on Product  = Combined Text of Product and Discount

lakshmanan_2-1665559749500.png

Note:Cannot use Merge and leftJoin, due to impact on other requirement.

Users are given Slicers for "Data from Date" and "Shipping Days"

lakshmanan_3-1665559844289.png


Default Filters handled in DAX:  Customer data should exclude Product "Misc" and shipping data should exclude Product "others"  .

CustomerCount = CALCULATE(DISTINCTCOUNT('Table 1'[CustomerID]),FILTER('Table 1','Table 1'[Product] <> "Misc"))
ShippingCount = CALCULATE(DISTINCTCOUNT('Table 2'[Shipping ID]),FILTER('Table 2','Table 2'[Product] <> "Others"))

 

When i try to get the Unmatched count of Customer ID with Filters
 i have blocked interaction between Shipping"Data from Date" slicer and result table.
Customer"Applied discount on product" matchs with the Shipping"Applied discount on product" on Old data on shipping table.
Example: User selected Customer"Data from Date" =10/4/2022 , Shipping"Data from Date" =10/11/2022"
Customer:

45432  Mobile - 23% Mobile 23% 10/4/2022

matchs with shipping on date 10/5/2022 and returns as "matched" . But its originally unmatched since user selected 10/11/2022 date in shipping . 

lakshmanan_6-1665562456051.png

 

 


If i allow the interaction between Shipping"Data from Date" slicer and result table. CustomerId's are excluded in result table.

lakshmanan_1-1665566975126.png

 


Please help to me create a DAX to get unmatched Count of Customer ID and 
Count of Shipping ID based on user selection mutiple slicers.


1 ACCEPTED SOLUTION
lakshmanan
Frequent Visitor

Issue has been resolved as below,

 

MisMatch1 = CALCULATE(COUNTROWS(FILTER('Table 1',NOT(CONTAINS('Table 2','Table 2'[Applied Discount on Product],'Table 1'[Applied Discount on Product])))),'Table 1'[Product]<>"Misc")
MisMatch2 = CALCULATE(COUNTROWS(FILTER('Table 2',NOT(CONTAINS('Table 1','Table 1'[Applied Discount on Product],'Table 2'[Applied Discount on Product])))),'Table 2'[Product]<>"Misc")Mismtach Counts.JPG
Also used Selectedcoumns to get the filtered column values from table 2 and matched against table1 using "not contains" to get the result.

View solution in original post

3 REPLIES 3
lakshmanan
Frequent Visitor

Issue has been resolved as below,

 

MisMatch1 = CALCULATE(COUNTROWS(FILTER('Table 1',NOT(CONTAINS('Table 2','Table 2'[Applied Discount on Product],'Table 1'[Applied Discount on Product])))),'Table 1'[Product]<>"Misc")
MisMatch2 = CALCULATE(COUNTROWS(FILTER('Table 2',NOT(CONTAINS('Table 1','Table 1'[Applied Discount on Product],'Table 2'[Applied Discount on Product])))),'Table 2'[Product]<>"Misc")Mismtach Counts.JPG
Also used Selectedcoumns to get the filtered column values from table 2 and matched against table1 using "not contains" to get the result.
v-jianboli-msft
Community Support
Community Support

Hi @lakshmanan ,

 

Please try:

First create a new table and apply it to the slicer to replace the slicer "Data from Date Table 2":

vjianbolimsft_1-1665646625612.png

Then create a measure and apply it to the filter:

Measure =
IF (
    ISFILTERED ( 'Data from Date Table 2'[Data from Date Table 2] ),
    IF (
        MAX ( 'Table 2'[Data from Date] )
            = SELECTEDVALUE ( 'Data from Date Table 2'[Data from Date Table 2] )
            || ISBLANK ( MAX ( 'Table 2'[Data from Date] ) ),
        1
    ),
    1
)

vjianbolimsft_2-1665647357180.png

Final output:

vjianbolimsft_3-1665647394909.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.

 

 

 

Hi @v-jianboli-msft ,
i have tried the steps, but totally there are 10 customers excluding "Misc" product , on filtering using measure on visual , only 2 matchs the shipping on 10/11/2022, so i would like to get unmatched count as 8 on customers. 
Also if i use card visual to display unmatched count, i couldnot apply measure filter on Card .
Is it possible to handle this in DAX query to get unmatched counts.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors