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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

How do you count the max and min in a column but you return the categorical data

Hey I have this table "Activities" with a column [ActivityType]. There are several different activities like "email" and "meeting". I want to have a count of what activity type is max and min and return what activity it is... not just the count. 

 

Right now I am doing these measures: 

 

Countactivity= COUNTROWS

MaxActivity= MAXX(VALUES(Activities[ActivityType]),[countactivity])

MinActivity = MINX (VALUES(Activities[ActivityType]), [countactivity]) 

 

I am getting 66K for the max and 108 for the min. How do I display what activity is associated to the max and min? 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

you can try this,

Count = CALCULATE(COUNTROWS(Activities),ALLEXCEPT(Activities,Activities[ActivityType]))
MaxActivity = 
var _max=MAXX(Activities,[Count])
return MAXX(FILTER(Activities,[Count]=_max),[ActivityType])
MinActivity = 
var _min=MINX(Activities,[Count])
return MAXX(FILTER(Activities,[Count]=_min),[ActivityType])

vxiaotang_0-1666605018024.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

you can try this,

Count = CALCULATE(COUNTROWS(Activities),ALLEXCEPT(Activities,Activities[ActivityType]))
MaxActivity = 
var _max=MAXX(Activities,[Count])
return MAXX(FILTER(Activities,[Count]=_max),[ActivityType])
MinActivity = 
var _min=MINX(Activities,[Count])
return MAXX(FILTER(Activities,[Count]=_min),[ActivityType])

vxiaotang_0-1666605018024.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , I have this code for date, but it should help in your case too

https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee884e

 

Use min in place of max for Minimum value

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.