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
Anonymous
Not applicable

Sum the Max within a grouped value

Hi there,

 

I'd like to calculate the following in a measure (see screenshot):

 

Capture.JPG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Check the measures as below.

Measure = 
var max_date = CALCULATE(MAX('Table'[date]),ALLEXCEPT('Table','Table'[plantid]))
return
IF(SELECTEDVALUE('Table'[date])=max_date,SUM('Table'[value]),BLANK())

Measure 2 = SUMX('Table',[Measure])

1.PNG

 

Best Regards,

Jay

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Check the measures as below.

Measure = 
var max_date = CALCULATE(MAX('Table'[date]),ALLEXCEPT('Table','Table'[plantid]))
return
IF(SELECTEDVALUE('Table'[date])=max_date,SUM('Table'[value]),BLANK())

Measure 2 = SUMX('Table',[Measure])

1.PNG

 

Best Regards,

Jay

mahoneypat
Microsoft Employee
Microsoft Employee

Here is a measure expression that should work.

 

RecentValue =
VAR vLastValue =
    SUMX (
        VALUES ( T1[PlantID] ),
        CALCULATE (
            LASTNONBLANKVALUE (
                T1[Date],
                AVERAGE ( T1[Value] )
            )
        )
    )
RETURN
    IF (
        OR (
            NOT (
                HASONEVALUE ( T1[PlantID] )
            ),
            MAX ( T1[Date] )
                CALCULATE (
                    MAX ( T1[Date] ),
                    ALLSELECTED ( T1[Date] )
                )
        ),
        vLastValue
    )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi there, thanks for your support.

Unfortunately, it does not the trick.

 

It shows me 15 on all rows where plantid is 456. I only want to see it on the row where the modification date = max date. 

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.