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
Anonymous
Not applicable

Top Name with count

Hi,

 

I'm trying to find the top partner name from the table below. 'Top' as in most leads, so I'm counting the leads per partner and wanting to return the name of the partner with the most leads.

I'm getting an error with the below code 'cannot convert value 'Tom' of type text to type true/false'.

 

I'd also like to be able to find the second best partner name as a separate query. Can you help please?

 

Top Partner = calculate(values('Leads+Exceptions'[PartnerName]),
filter(values('Leads+Exceptions'[PartnerName]),
if(
rankx(
all('Leads+Exceptions'[PartnerName]),count('Leads+Exceptions'[LeadKey]),,DESC)=1,
'Leads+Exceptions'[PartnerName],BLANK()
)

))

 

I also tried with this formula that I got from thread 'Dax top 1 name' in this forum:

 

Top ISV = calculate(max('Leads+Exceptions'[PartnerName]),
filter(values('Leads+Exceptions'[PartnerName]),
rankx(
all('Leads+Exceptions'[PartnerName]),count('Leads+Exceptions'[LeadKey]),,desc)<=2),USERELATIONSHIP('Date'[calendar_date],'Leads+Exceptions'[LeadMonth])

)

 

It gave no errors, but it's not giving the correct result. Perhaps it's not 'grouping' the names together before doing a count, so it's counting each row as 1? My table is akin to the below but obv much bigger!

 

sampledata.JPG

2 REPLIES 2
LivioLanzo
Solution Sage
Solution Sage

@Anonymous

 

how do you want to return it? in a measure? as a table?

 

here is a calculated table that will return the top 1

 

 

Table =
TOPN (
    1,
    SUMMARIZECOLUMNS (
        'Leads+Exceptions'[PartnerName],
        "Count"COUNTROWS ( 'Leads+Exceptions' )
    ),
    [Count], DESC
)

 


 


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


Proud to be a Datanaut!  

Anonymous
Not applicable

As a measure.

 

I'd want it to be adaptable so I can change it to find the 2nd as well (in a separate measure).

 

Thanks

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.