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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BH22One
Helper I
Helper I

Max Value of a Category

Good Afternoon,

 

I am struggling with a solution in Power BI that would give me the Maximum Sales of a Product Category for a particular day.

 

I used Max Sales = MAX('Table' [Sales]) to find the maximum value in the entire table.

 

I tried using Max Category Sales = CALCULATE(MAX('Table'[Sales]),ALLEXCEPT('Table','Table'[PRODUCT_ID]) however it returns the same value as the calculation above. I need it to ignore Field 2 (or Product ID) and give the max of the entire category over a period of time.

 

Based on the picture below, I need the "Max Category Sales" Card to equate to the maximum value for the category shown in the table below the card of 5,186.

 

ex.PNG

Thanks in advance on any help with this.

 

-BSH

 

 

1 ACCEPTED SOLUTION

Hi @BH22One ,

 

We can use the following measure to meet your requirement.

 

max category =

CALCULATE (

    MAXX (

        DISTINCT ( 'Table'[POSTING_DT] ),

        CALCULATE ( SUM ( 'Table'[Sales] ) )

    ),

    ALLSELECTED ( 'Table' )

)

 

Then we can get the result like this,

 

31.png

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
Syndicate_Admin
Administrator
Administrator

Good afternoon community. I have the following problem: I want the total of my Category to see the same value as this in all subcategories and not to add it, as I can do.

YeffersonAndres_0-1694725535406.png

I would appreciate your help!

Hi,

This pattern should work

Measure = if(hasonevalue(Data[Categpria]),[activas_campanial],minx(all(Data[Categpria]),[activas_campanial]))

Hope this helps.


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

Hi,

Assuming the following are true:

  1. There is a Calendar Table with a relationship to the Date column of Table; and
  2. To your visual, drag Year and Date from the Calendar Table; and
  3. In the slicer/filter, select Headphones
  4. "Total sales value" is a measure which is calculated as =SUM('Table'[Sales])

write this measure

Max sales for chosen category on any day = MAXX(SUMMARIZE(Calendar,Calendar[Date],"ABCD",[Total sales value]),[ABCD])

If this does not help, then share the link from where i can download your PBI file.

 


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

I would think:

= CALCULATE(MAX('Table'[Sales]),ALLEXCEPT('Table','Table'[CATEGORY])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Good Afternoon @Greg_Deckler ,

 

I tried your suggestion and unfortunately it gives me the same output as before 😞

 

Hi @BH22One ,

 

We can use the following measure to meet your requirement.

 

max category =

CALCULATE (

    MAXX (

        DISTINCT ( 'Table'[POSTING_DT] ),

        CALCULATE ( SUM ( 'Table'[Sales] ) )

    ),

    ALLSELECTED ( 'Table' )

)

 

Then we can get the result like this,

 

31.png

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lid-msft This solution worked perfectly.

 

Thanks a ton!

OK, can you share sample data then so I can test this out and get a working solution. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.