Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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.
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.
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:
sample data:
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 9 | |
| 6 | |
| 5 |
| User | Count |
|---|---|
| 27 | |
| 22 | |
| 19 | |
| 17 | |
| 11 |