Forum Discussion

Daniel48's avatar
Daniel48
Helper I
2 years ago
Solved

Adding Calculated Column with the latest Item

Hello,

 

I have tried many different ways and I can not seem to make this work.

 

I have a list of items  

Category    Date  Current           New Colum

X01  01/01/2018    ABC                 ABD

X01 01/01/2019     ABC                 ABD

X01 01/01/2020     ABC                 ABD

X01 01/01/2021     ABC                 ABD  

X01 01/01/2022    ABD                  ABD

X02 01/01/2023 

X03

 

I am trying to get the new column to pull the latest item 01/01/2022 for category X01. I can get it for the whole data set but not for each category

 

 

Thank you in Advance,

 

 

 

  • You can use the following DAX formula to create a calculated column:

     

    Latest Value = 
    VAR _currentCategory = Data[Category]
    VAR _maxDate =
        CALCULATE (
            MAX ( Data[Date] ),
            FILTER ( Data, Data[Category] = _currentCategory )
        )
    VAR _leastVal =
        CALCULATE (
            MAX ( Data[Current] ),
            FILTER ( Data, Data[Date] = _maxDate && Data[Category] = _currentCategory )
        )
    RETURN
        _leastVal

     

    Here is the solution screenshot:

    Make sure to leave a kudo if it resolves your issues...

     

    Thanks 😊

     

     

     

9 Replies

  • You can use the following DAX formula to create a calculated column:

     

    Latest Value = 
    VAR _currentCategory = Data[Category]
    VAR _maxDate =
        CALCULATE (
            MAX ( Data[Date] ),
            FILTER ( Data, Data[Category] = _currentCategory )
        )
    VAR _leastVal =
        CALCULATE (
            MAX ( Data[Current] ),
            FILTER ( Data, Data[Date] = _maxDate && Data[Category] = _currentCategory )
        )
    RETURN
        _leastVal

     

    Here is the solution screenshot:

    Make sure to leave a kudo if it resolves your issues...

     

    Thanks 😊

     

     

     

      • quantumudit's avatar
        quantumudit
        Super User

        Happy to help 😊

         

        Best Regards,
        Udit

        If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
        Appreciate your Kudo 👍

        🚀 Let's Connect: LinkedIn || YouTube || Medium || GitHub
        Visit My Linktree: LinkTree