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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
aashton
Helper V
Helper V

Find the category with the most IDs

Hello,

I have a table that has ID, Name, date, ......, lead_source.  I'm trying to find the name of the lead_source with the most ID's to put in a card.   Need help with the code....Thanks.

2 REPLIES 2
adudani
Super User
Super User

Hi @aashton ,

 

create a table using this:

Measure = 
var _table =
TOPN(1,
Summarize 
(
'Table (2)',
'Table (2)'[Lead_Source],
"Max ids", SUM('Table (2)'[ID])
),
[Max ids],DESC
)
return
_table

 

create this measure= 

 

Measure = 
SELECTEDVALUE( 'Measure'[Lead_Source])

 

let me know if this resolves the problem.

 

Appreciate a thumbs up if this is helpful.

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash
FreemanZ
Super User
Super User

hi @aashton 

please try like:

lead_source with the most ID = 
VAR _list = VALUES(TableName[lead_source])
VAR _MaxID =
MAXX(
    _list,
    CALCULATE(COUNTROWS(TableName))
)
RETURN
FILTER(
    _list,
    CALCULATE(COUNTROWS(TableName) = _MaxID)
)

 

verified with a simplified sample data and it worked like this:

FreemanZ_0-1674688868790.png

sample data:

FreemanZ_1-1674688885776.png

 

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.