Forum Discussion

russell80's avatar
russell80
Helper III
3 years ago
Solved

Help Grouping and Summing Latest Records

helpI have a table with the following structure:

 

CategoryColourDateValue 
DogBrown01/01/20231 
DogBlack02/01/20230 
DogYellow03/01/20230Sum this
CatWhite04/01/20231 
CatBlack05/01/20231 
CatGinger06/01/20230Sum this
MouseWhite07/01/20231 
MouseGrey08/01/20230 
MouseBlack09/01/20231Sum this

 

I'm trying to write a measure that sums the value column for the latest record of each Category. In this example the result would be 1. After much googling and chatgpt, I'm still stuck! Any help would be appreciated!

I also have a filter on the table visual that filters the date column, and I have a slicer that that slices the Colour column.

  • Hi russell80 
    Please try

    ResultMeasure =
    SUMX (
        SUMMARIZE (
            'Table',
            'Table'[Category],
            "@Value", SUMX ( TOPN ( 1, 'Table', 'Table'[Date] ), 'Table'[Value] )
        ),
        [@Value]
    )

1 Reply

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi russell80 
    Please try

    ResultMeasure =
    SUMX (
        SUMMARIZE (
            'Table',
            'Table'[Category],
            "@Value", SUMX ( TOPN ( 1, 'Table', 'Table'[Date] ), 'Table'[Value] )
        ),
        [@Value]
    )