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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
cyberdejy
Regular Visitor

Return max monthly output value

Hi,

I have a DAX for highest Daily and Monthly sales.

The daily formula works perfectly when whatever I select it just gives me the highest daily output - no problem.

But when I want to get the month with the highest output it just sums the months with the highest value from each year for some reason..

When I select from the Date slicer month by month is OK, but if I select 2 years or more or if there is no selection at all it returns the sum of all months instead of the highest month output.

Here are the calculations for both Max daily and Max Monthly:

Max Daily O/Put = MAXX(VALUES('Calendar'[Date].[Date]),CALCULATE(sum('COEX - List'[Output Kg]))) //this one is working without any issues
Max Monthly O/Put = MAXX(VALUES('Calendar'[Date].[Month]),CALCULATE(SUM('COEX - List'[Output Kg]))) //not working if selected two or more years from the slicer.
 
I don't know what I'm doing wrong..
Thanks

 

4 REPLIES 4
Anonymous
Not applicable

Hi  @cyberdejy ,

I created some data:

vyangliumsft_0-1683015652396.png

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _select = SELECTCOLUMNS('Table',"1",[Year])
return
FORMAT(
MAXX(
    FILTER(ALL('Table'),'Table'[Value]=
MAXX(
    FILTER(ALL('Table'),'Table'[Year] in _select),[Value])),[Date]),"mmmm")

2. Result:

vyangliumsft_1-1683015652408.png

 

Best Regards,

Liu Yang

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

Hi and thanks for your feedback.

The way I see your example table - the highest value in year 2022 is (24) and the highest value in 2023 is (26) .. All I want is to have as a result when selecting both year 2022 and 2023 to get the highest value which is 26.

And if I select all three years then it should return (39) as the highest day value as per your example.

cyberdejy_0-1683019893636.png

At the moment as it happend before with my tables when selecting multiple years it returns the sum instead of the single highest value accross all years.

cyberdejy_1-1683020010037.png

 

Thejeswar
Super User
Super User

Hi @cyberdejy ,

I think the problem is what the DAX you have written.

I the DAX you have shared, there is a SUM function which I think is performing the sum of Values. In a day where there is a single entry, your DAX might work, but for days with multiple values for it, this should still be an issue

Try removing the SUM and see.

Max Daily O/Put = MAXX(VALUES('Calendar'[Date].[Date]),CALCULATE('COEX - List'[Output Kg]))
Max Monthly O/Put = MAXX(VALUES('Calendar'[Date].[Month]),CALCULATE('COEX - List'[Output Kg]))
 
Regards,
 
 

Hi and thanks for the reply. It must have sum as its not a measure so it need to sum all the values in this column (Output Kg) and bring the max value for the selected period. For example if I select years 2023,2022,2021 etc. I want as ruturn the month with the highest value.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors