Latest Date Value in Attribute

Oprick
Oprick New Altair Community Member
edited November 2024 in Community Q&A
Hi,
I bet this is a very easy one, but... how do I get the latest (Max) date value in a data set?

Regards 
Tagged:

Best Answer

  • kayman
    kayman New Altair Community Member
    Answer ✓
    You need to take 2 steps in this case (if I understood the question correctly). First generate a macro value on the full set storing the max date value, then you generate your attributes using the stored macro value as reference. So your expression becomes something like this ; if(date<%{my_stored_max_value},"1","0") 

    Now, since macros are stored as strings it will probably be easier to convert your date to millisecs and parse the macro, so something like this : if(date_millis([my_date_field])<parse(%{my_stored_max_value})),"1","0")

Answers

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Hi,
    Either Sort + Filter Example Range
    or
    Aggreage on maximum(date)

    Best,
    Martin
  • Telcontar120
    Telcontar120 New Altair Community Member
    If it is already stored as a date/time data type, you can also simply check the Statistics view---that will show you the min and max date plus total duration of all date/time attributes in your dataset.

  • Oprick
    Oprick New Altair Community Member
    Hi,
    Thank you for your prompt replies.
    Sorry I guess that my question was not clearly put. I want to be able to refer to max(date) in generate attributes. Something like: if(date<max(date),"1","0").

    tks



  • kayman
    kayman New Altair Community Member
    Answer ✓
    You need to take 2 steps in this case (if I understood the question correctly). First generate a macro value on the full set storing the max date value, then you generate your attributes using the stored macro value as reference. So your expression becomes something like this ; if(date<%{my_stored_max_value},"1","0") 

    Now, since macros are stored as strings it will probably be easier to convert your date to millisecs and parse the macro, so something like this : if(date_millis([my_date_field])<parse(%{my_stored_max_value})),"1","0")

  • Oprick
    Oprick New Altair Community Member
    Hy,
    @kayman thanks. Worked like charm.

    Thank you,
    Pedro