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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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