cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
j3sting Frequent Visitor
Frequent 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

Accepted Solutions
Highlighted
OwenAuger Super Contributor
Super Contributor

Re: Return Name of User With Highest Number of Clients

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 🙂



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post

4 REPLIES 4
Highlighted
OwenAuger Super Contributor
Super Contributor

Re: Return Name of User With Highest Number of Clients

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 🙂



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post

v-haibl-msft Super Contributor
Super Contributor

Re: Return Name of User With Highest Number of Clients

@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

j3sting Frequent Visitor
Frequent Visitor

Re: Return Name of User With Highest Number of Clients

Hi OwenAuger 

 

Perfect thanks! 🙂 and thank you for replying 🙂

j3sting Frequent Visitor
Frequent Visitor

Re: Return Name of User With Highest Number of Clients

thanks Herbert_Liu

 

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

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 54 members 857 guests
Please welcome our newest community members: