Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Latest Date per Group

Hello,

How do I identify the latest date (based on the BusinessDate per ProductCode (as each productcode could have a different Latest Date)
If it is the Latest Date per productcode then = 1 else 0

The following only identifies the lastest date available over the whole table, but doesn't consider per productcode which could differ for each code.
Latest Date = IF('Test'[BusinessDate]= max('Test'[BusinessDate]),1,0)

  • Hey,

     

    assuming my table looks like this:

    I can use this DAX to create a calculated olumn:

    flag the latest date = 
    var _ProductCode = 'Table'[ProductCode]
    var latestDate = 
        MAXX(
            FILTER(
                ALL('Table')
                , 'Table'[ProductCode] = _ProductCode
            )
            , [BusinessDate]
        )
    return
    IF('Table'[BusinessDate] = latestDate , 1 , 0)

    The final table then will look like this:

     

    Hopefully this is what you are looking for.

     

    Regards,

    Tom

     

3 Replies

  • Hey,

     

    assuming my table looks like this:

    I can use this DAX to create a calculated olumn:

    flag the latest date = 
    var _ProductCode = 'Table'[ProductCode]
    var latestDate = 
        MAXX(
            FILTER(
                ALL('Table')
                , 'Table'[ProductCode] = _ProductCode
            )
            , [BusinessDate]
        )
    return
    IF('Table'[BusinessDate] = latestDate , 1 , 0)

    The final table then will look like this:

     

    Hopefully this is what you are looking for.

     

    Regards,

    Tom

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you Tom!

       

      • TomMartens's avatar
        TomMartens
        Super User
        Hey,

        if my previous post solves your problem, please mark it as an answer, as it will help others to find a solution.

        Regards,
        Tom