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
j3sting
Regular Visitor

Return Name of User With Highest Number of Clients

Hi,

 

Looking for some help please, im trying to create a measure to retrieve the name of the user with the highest number of clients, my columns are "Keyworker" (this is the user) and "carerid"  (this is the client).

 

I have tried and failed to get this to work, it would be great if someone could point me in the right direction.

 

thanks

 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @j3sting

 

You can use a pattern like this (pattern taken from SQLBI - Alternative use of FIRSTNONBLANK and LASTNONBLANK😞

 

TopUser =
FIRSTNONBLANK (
    TOPN (
        1,
        VALUES ( YourTable[Keyworker] ),
        CALCULATE ( DISTINCTCOUNT ( YourTable[carerid] ) )
    ),
    1
)

The FIRSTNONBLANK is just there to break ties.

 

Owen 🙂


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

4 REPLIES 4
v-haibl-msft
Employee
Employee

@j3sting

 

You can also use the RANKX function to rank the client numbers and get the user name whose rank number is 1.

Assuming we have a table like below.

Return Name of User With Highest Number of Clients_1.jpg

 

We can create two measures with following formulas.

Rank_Client =
RANKX ( ALLSELECTED ( Table1 ), CALCULATE ( SUM ( Table1[carerid] ) ) )
Highest = 
CALCULATE (
    ALLSELECTED ( Table1[Keyworker] ),
    FILTER (
        ADDCOLUMNS ( VALUES ( Table1[Keyworker] ), "RankNum", [Rank_Client] ),
        [RankNum] = 1
    )
)

Return Name of User With Highest Number of Clients_2.jpg

 

Best Regards,

Herbert

thanks Herbert_Liu

 

another great sollution, thanks for the help much appreciated! 🙂

OwenAuger
Super User
Super User

Hi @j3sting

 

You can use a pattern like this (pattern taken from SQLBI - Alternative use of FIRSTNONBLANK and LASTNONBLANK😞

 

TopUser =
FIRSTNONBLANK (
    TOPN (
        1,
        VALUES ( YourTable[Keyworker] ),
        CALCULATE ( DISTINCTCOUNT ( YourTable[carerid] ) )
    ),
    1
)

The FIRSTNONBLANK is just there to break ties.

 

Owen 🙂


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Hi OwenAuger 

 

Perfect thanks! 🙂 and thank you for replying 🙂

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.