Forum Discussion

BH22One's avatar
BH22One
Helper I
6 years ago
Solved

Display data form Max Year in data set

Good Afternoon, I am struggling to create a Custom Measure that will calculate the sum of a column while filtering on the Maximum Year Number in a difference column within the same table.   I am c...
  • jdbuchanan71's avatar
    6 years ago

    Hello BH22One 

    Give this a try.  It uses ALL ( Product ) to clear the filter context then calc the max year in a variable.  Then it uses the variable in the calc.  The KEEPFILTERS is to stop the amount from appearing in the other years.

    Max Year Sales = 
    VAR MaxProductYear = CALCULATE ( MAX ( 'Product'[Year] ) , ALL ( 'Product' ) )
    
    RETURN
    CALCULATE(
        SUM('Product'[Units]),
        KEEPFILTERS( 'Product'[Year]  = MaxProductYear ) )