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
metcala
Helper III
Helper III

Count number who have purchased both products

Hi

 

Sorry for the simple question....

 

CustomerProduct
A1
A2
B1
C1
D1
D2

 

I'm looking to count how many customers have purchased 1 and 2 so in the above example I'd expect 2 (A and D).

 

I've currently got the following but doesn't seem to be working:

 

=CALCULATE(DISTINCTCOUNT('table'[Customer]),FILTER('table',[Product]="1"&&[Product]="2"))

 

Any help would be much appreciated!

3 ACCEPTED SOLUTIONS

Hi, @metcala 

Measure 2 = 
var a = CALCULATE(MIN('count'[Customer]),'count'[Product]=1)
var b = CALCULATE(MIN('count'[Customer]),'count'[Product]=2)
return 
CALCULATE(COUNT('count'[Customer]),'count'[Customer]=a && 'count'[Customer]=b)

 

Dangar332_0-1698422926173.png

 

View solution in original post

Hi, @metcala 

 

try below code 

result = var a = ADDCOLUMNS(
          ALL('count'[Customer]),
           "for 1",  CALCULATE(
                            MIN('count'[Customer]),
                           'count'[Product]=1
                              ),

            "for 2", CALCULATE(
                          MIN('count'[Customer]),
                            'count'[Product]=2
                              )
                    )
return 
 COUNTX(
    FILTER(a,
    NOT([for 1]="")&&
    NOT([for 2]="")
       ),
       'count'[Customer]
       )

 

Dangar332_0-1698661195828.png

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. and don't forget to give kudos.

View solution in original post

Hi, @metcala 

is above code work for you or not?

View solution in original post

7 REPLIES 7
metcala
Helper III
Helper III

Hi

 

Thanks for the response.

 

I don't think I was clear in my original post. There are other products but I am only after a measure that counts specifically product 1 and product 2.

Hi, @metcala 

Measure 2 = 
var a = CALCULATE(MIN('count'[Customer]),'count'[Product]=1)
var b = CALCULATE(MIN('count'[Customer]),'count'[Product]=2)
return 
CALCULATE(COUNT('count'[Customer]),'count'[Customer]=a && 'count'[Customer]=b)

 

Dangar332_0-1698422926173.png

 

Thanks for your help with this one. I have just tried adding to my dataset and the measure keeps returning 2 on the data card rather than a count of the number of applications

 

It is working correctly when added to a matrix for Customer ID and Measure but I just need a card with the number of customers with both products.

 

e.g. with the following dataset I'd expect the card to display 4

 

CustomerProduct
A1
A2
B1
C1
D1
D2
E1
E2
F2
G1
G2

Hi, @metcala 

 

try below code 

result = var a = ADDCOLUMNS(
          ALL('count'[Customer]),
           "for 1",  CALCULATE(
                            MIN('count'[Customer]),
                           'count'[Product]=1
                              ),

            "for 2", CALCULATE(
                          MIN('count'[Customer]),
                            'count'[Product]=2
                              )
                    )
return 
 COUNTX(
    FILTER(a,
    NOT([for 1]="")&&
    NOT([for 2]="")
       ),
       'count'[Customer]
       )

 

Dangar332_0-1698661195828.png

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. and don't forget to give kudos.

Hi, @metcala 

is above code work for you or not?

Sorry for late response, that's perfect! Thank you!!

Dangar332
Super User
Super User

hi, @metcala 

 

try below

 

 

 COUNTX(FILTER('count',COUNT('count'[Product])>1),'count'[Customer])

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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