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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Get Minimum and Maximum of Count

I have a categorical feature.

I want to get the maximum count and minimum count of categories in a column. That is, highest and and lowest counts (range).

How can I do that?

 

Here is an example:

 

Category
AAA
AAA
BBB
BBB
AAA
BBB
AAA
CCC

 

Maximum count is related to AAA which is 4

Minimum count is related to CCC which is 1.

 

I want to get 4 and 1 in two dax measures.

 

Thanks.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try these measures:

Count = COUNTROWS(Data)
Maximum count = MAXX ( VALUES(Data[Category]), [Count] )
Minimum count = MINX ( VALUES(Data[Category]), [Count] )

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

https://www.dropbox.com/s/qcc42kg4ste44dr/Mah65.pbix?dl=0 

 

 

Min Count Category =

MINX (
GROUPBY (
ALL ( 'Table' ),
'Table'[Category],
"@maxcount", SUMX ( CURRENTGROUP (), 1 )
),
[@maxcount]
)
 
 
Max Count Category =

MAXX (
GROUPBY (
ALL ( 'Table' ),
'Table'[Category],
"@maxcount", SUMX ( CURRENTGROUP (), 1 )
),
[@maxcount]
)
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Ashish_Mathur
Super User
Super User

Hi,

Try these measures:

Count = COUNTROWS(Data)
Maximum count = MAXX ( VALUES(Data[Category]), [Count] )
Minimum count = MINX ( VALUES(Data[Category]), [Count] )

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

So this worked for me. But I am wondering if there is a way to alter it. I have a table Activities that have a column [ActivityType]. I was able to count the max and min activies but I want it to return what that activity is. For example "email" is the max activity, how do I return that instead of the count? 

Hi,

Share data in a format that can be pasted in an MS Excel file and show the expected result. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thank you very much.

I don't know why it didn't fully work with my measures and filters and data. Probably, because I had some null values in the main data. This modified version solved my problem. 

 

 

Count = COUNTA('Data'[Category])

 

 

The rest is the same.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
danextian
Super User
Super User

Hi @Anonymous ,

 

Try these:

MaxCount =
MAXX (
    SUMMARIZE (
        'Table',
        'Table'[Category],
        "count",
            CALCULATE (
                COUNTA ( 'Table'[Category] ),
                ALLEXCEPT ( 'Table', 'Table'[Category] )
            )
    ),
    [count]
)


MinCount =
MINX (
    SUMMARIZE (
        'Table',
        'Table'[Category],
        "count",
            CALCULATE (
                COUNTA ( 'Table'[Category] ),
                ALLEXCEPT ( 'Table', 'Table'[Category] )
            )
    ),
    [count]
)




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors