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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
009co
Helper IV
Helper IV

DAX Measure to calculate a sum by date of max values by date and location columns

I want to use DAX to calculate a daily sum of max values grouped by by date and location. 

 

The starting data looks like the table below.

 

DateLocationValue
2022-03-01A10
2022-03-01B20
2022-03-01A30
2022-03-01B5
2022-03-02A20
2022-03-02B40
2022-03-02A5
2022-03-02B10
   

 

First step is to get max values by date and location

   
DateLocationMax Value
2022-03-01A30
2022-03-01B20
2022-03-02A20
2022-03-02B40
   
Second step is to get sum of max values by date 
   
DateSum Max Value 
2022-03-0150 
2022-03-0260 

 

Can this be done in a single DAX Measure?

 

I already have a DAX measure that calculates a sum of max values by location:

 

Sum Max Location Values = SUMXVALUES 'Table'[Location] ), CALCULATEMAX'Table'[Values] )))

 

 

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Sum of max values = SUMX(
ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[Date], 'Table'[Location]), "@val", 
    CALCULATE( MAX( 'Table'[Value])) ),
[@val] )

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the picture down below and the attached pbix file.

One is for creating a new table, and the other is for creating a measure.

 

Picture1.png

 

Desired table = 
VAR stepone =
    GROUPBY (
        Data,
        Data[Date],
        Data[Location],
        "@maxvalue", MAXX ( CURRENTGROUP (), Data[Value] )
    )
VAR steptwo =
    GROUPBY (
        stepone,
        Data[Date],
        "@SumMaxValue", SUMX ( CURRENTGROUP (), [@maxvalue] )
    )
RETURN
    steptwo

 

Desired measure: =
VAR stepone =
    GROUPBY (
        Data,
        Data[Location],
        "@maxvalue", MAXX ( CURRENTGROUP (), Data[Value] )
    )
RETURN
    IF ( HASONEVALUE ( Data[Date] ), SUMX ( stepone, [@maxvalue] ) )


Microsoft MVP



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.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



johnt75
Super User
Super User

Sum of max values = SUMX(
ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[Date], 'Table'[Location]), "@val", 
    CALCULATE( MAX( 'Table'[Value])) ),
[@val] )

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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