Forum Discussion

Mat42's avatar
Mat42
Resolver I
4 years ago
Solved

Max/Min Calculated Column

This is either going to be easy or horribly complicated.   Let's say I ave a simple table of data:   Name Date Dave 01/01/2021 Dave 01/01/2021 Dave 02/02/2019 Dave 01/01/2021 ...
  • bcdobbs's avatar
    4 years ago

    Your calculated column needs to look like:

    Min Date = 
        CALCULATE (
            MIN ( Person[Date] ),
            ALLEXCEPT( Person, Person[Name] )
        )


    If you just did MIN on it's own it would find the minimum date in the whole column.

    CALCULATE forces a context transition that moves all the columns in the current row into the filter context.

    However CALCULATE ( MIN ( Person[Date] ) ) will just return the date of the current row because CALCULATE has included the date column in the filter.

     

    The solution above tells calculate to remove the filters from everything apart from Person[Name].