Forum Discussion

ggzmorsh's avatar
ggzmorsh
Helper II
5 years ago
Solved

Calculate Max to Return Text

I have Table1 which contains 4 ID occurrences in 4 different dates/times and 4 different remarks. What i wanted to do is to return the last occurring remark from the last date or most recent.   I t...
  • v-kelly-msft's avatar
    v-kelly-msft
    5 years ago

    Hi ggzmorsh ,

     

    You could first create an index column,then create a measure as below:

    Measure = 
    var _maxdate=CALCULATE(MAX('Table'[Date]),ALL('Table'))
    VAR _index=CALCULATE(MAX('Table'[Index]),FILTER(ALL('Table'),'Table'[Date]=_maxdate))
    Return
    CALCULATE(MAX('Table'[Remarks]),FILTER('Table','Table'[Index]=_index))

    Or if you need a calculated column,you could use below dax expression:

    Column = 
    var _maxdate=CALCULATE(MAX('Table'[Date]),ALL('Table'))
    var _index=CALCULATE(MAX('Table'[Index]),FILTER('Table','Table'[Date]=_maxdate))
    Return
    CALCULATE(MAX('Table'[Remarks]),FILTER('Table','Table'[Index]=_index))

    And you will see:

     

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my post as a solution!