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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

I would think:

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

@ 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!:
The Definitive Guide to Power Query (M)

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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.