Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Look up value based on two criteria?

So I have 3 columns involved in this issue. [Name], [Date], and [ID]. The [ID] column is unique but can contain multiple [Name] values for each [ID]. What I want to return is the most recent [Name] based on the [ID] using the [Date] column. How would I go about doing this?

  • Anonymous try followin measure

     

    Recent Name = 
    VAR __latestDate = 
    CALCULATE( 
    MAX( Table[Date]),
    ALLEXCEPT( Table, Table[Id])
    )
    RETURN
    CALCULATE(
    MAX( Table[Name]),
    Table[Date] = __latestDate
    )

    Add a table visual, put Id and Recent Name measure on and you will have the result

5 Replies

  • Anonymous try followin measure

     

    Recent Name = 
    VAR __latestDate = 
    CALCULATE( 
    MAX( Table[Date]),
    ALLEXCEPT( Table, Table[Id])
    )
    RETURN
    CALCULATE(
    MAX( Table[Name]),
    Table[Date] = __latestDate
    )

    Add a table visual, put Id and Recent Name measure on and you will have the result

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you parry2k. Is there a way to do this but for a calculated column instead?

      • Anonymous's avatar
        Anonymous
        Not applicable

        Any other ideas? I need a calculated column as I need to use a matrix instead of a table.