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! Request now

Reply
MarcoSilva
New Member

Sum the values only for the MAX category by month

Hello!

 

I'm having trouble to create a DAX measure where I need to sum only the values of the lines where the category is the max category of the month.

 

Below is the sample data:

MarcoSilva_0-1677183971302.png

 

The measures I created are these:

SumCategories =
CALCULATE(
    SUM([Value]),
    FILTER(Sheet1, [Type] = "A"),
    FILTER(Sheet1, [Category] = MAX(Sheet1[Category]))
)
 
And this one where I get the accumulated value by month:
SumCategoriesYTD =
TOTALYTD(
    [SumCategories],
    Sheet1[Date],
    "09/30"
)
 
I also created a measure to check what is the max category of the month:
MaxCategory = MAX(Sheet1[Category])
 
The result is below:
MarcoSilva_1-1677184213422.png

The values in the SumCategories and the MaxCategory for each month are ok, but the totals and the SumCategoriesYTD are terribly wrong. Anyone can help me with that?

 

Here are the expected values:

MarcoSilva_2-1677184435792.png

Thanks in advance.

1 ACCEPTED SOLUTION
andhiii079845
Solution Sage
Solution Sage

Hi,

try this DAX

SumCategories_new = 

Var tbl =  SUMMARIZE(Tabelle4,Tabelle4[Date],"sumcategorie",[SumCategories])

RETURN sumx(tbl,[sumcategorie])
You have to change the Table name in the formular.

If you want MaxCategory without total try this:

MaxCategory = IF(HASONEFILTER(Tabelle4[Date]),MAX(Tabelle4[Category]),BLANK())
andhiii079845_1-1677236164810.png

 

A good link: https://www.vahiddm.com/post/why-my-measure-returns-the-wrong-total

 




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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
andhiii079845
Solution Sage
Solution Sage

Hi,

try this DAX

SumCategories_new = 

Var tbl =  SUMMARIZE(Tabelle4,Tabelle4[Date],"sumcategorie",[SumCategories])

RETURN sumx(tbl,[sumcategorie])
You have to change the Table name in the formular.

If you want MaxCategory without total try this:

MaxCategory = IF(HASONEFILTER(Tabelle4[Date]),MAX(Tabelle4[Category]),BLANK())
andhiii079845_1-1677236164810.png

 

A good link: https://www.vahiddm.com/post/why-my-measure-returns-the-wrong-total

 




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

Proud to be a Super User!




Hi @andhiii079845!

Your contribution worked perfectly!

Thank you very much.

MarcoSilva
New Member

Hi @Greg_Deckler, thanks for the contribution.

It helped me to better understand the problem but yet I can't figure out how to resolve it.

Anyone else?

Greg_Deckler
Community Champion
Community Champion

@MarcoSilva First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.