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

Win a FREE 3 Day Ticket to FabCon Vienna. Apply now

Reply
bmcomp
Regular Visitor

Distinct Count where columns match

Hi All,

 

I have two queries joined by a key. The two queries are Customer details & Responses.  I want to get a count of how many unique customers that have responses.  A customer can have more than one response but i just want to count that customer once.

 

I want to do something like this:

DISTINCTCOUNT (CustomerName) WHERE 'CustomerDetails'[Key] = 'Responses'[Key]

 

Any help would be great

 

Thanks

B

 

1 ACCEPTED SOLUTION

@bmcomp

Can you have a try

No of Customers have at least one response =
COUNTROWS (
    FILTER (
        Customers,
        IF (
            ISBLANK (
                LOOKUPVALUE (
                    Response[CustomerID],
                    Customers[CustomerID], Customers[CustomerID]
                )
            ),
            0,
            1
        )
    )
)

View solution in original post

4 REPLIES 4
Eric_Zhang
Microsoft Employee
Microsoft Employee

@bmcomp

 

Say the two tables are as below and a proper relationship is created. Check a measure like

 

No of Customers have at least one response = COUNTROWS(FILTER(Customers,LOOKUPVALUE(Response[CustomerID],Customers[CustomerID],Customers[CustomerID])))

 

Capture.PNG

 

Hi @Eric_Zhang

 

Thanks for the reply.  My key is an alphamumeric key and as such the LOOKUPVALUE command will not work.  It will work perfectly if my key was an integer.  I may be able to do some transformation on the column to solve this if there is no other way.

 

Do you know of any workaround for alphanumeric values?

 

Thanks

Brian

@bmcomp

Can you have a try

No of Customers have at least one response =
COUNTROWS (
    FILTER (
        Customers,
        IF (
            ISBLANK (
                LOOKUPVALUE (
                    Response[CustomerID],
                    Customers[CustomerID], Customers[CustomerID]
                )
            ),
            0,
            1
        )
    )
)

Hi @Eric_Zhang

 

That works perfect.  I really appricate your help on this!

 

Regards

Brian

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.