🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to create an attribute with the difference

User: "hugomsouto"
New Altair Community Member
Updated by Jocelyn
Hi, everyone.

I am stucked. I need to create an attribute with the difference betweem a value from another attribute of the same row and the value of that same attribute from the row just above.

In Excel, it would be like, on the colum "=[@[lanData_time]]-A(numer of the row just above)". Anyone could help me?

Thanks!

Find more posts tagged with

Sort by:
1 - 6 of 61
    User: "jacobcybulski"
    New Altair Community Member
    Updated by jacobcybulski
    OK, here is not a very elegant solution. Let's say we want to find the difference between people's ages (Age attribute). I have create an attribute to collect differences (AgeDiff) and they are undefined. Set a macro (such as PrevAge) with the initial value of the attribute of interest (Age), here is zero. Then loop over your examples.
    At each iteration:

    Extract the value of the attribute of interest into macro CurrAge, calculate difference between  CurrAge and PrevAge and save it in AgeDiff macro, then set the value of the attribute AgeDiff in the example pointed to by the loop index to the value of macro AgeDiff, finally set the macro PrevAge to CurrAge.

    Done:

    Jacob (see the example attached as RMP)
    User: "jacobcybulski"
    New Altair Community Member
    This one is probably even less elegant and definitely not as efficient.



    You duplicate you input, add a dummy example to the copy, merge them both placing the values of the preceding attribute with the next, calculate the difference, get rid of extra example at the end (somehow) and select only the attributes of interest (because of duplicated attributes).

    Jacob

    User: "Telcontar120"
    New Altair Community Member
    Have you tried the Lag operator from the Time Series group of operators?

    User: "jacobcybulski"
    New Altair Community Member
    Great idea @Telcontar120 in which case we do not need to make this awkward duplication and merging of out of sync example sets.
    User: "tftemme"
    New Altair Community Member
    Accepted Answer
    Hi @hugomsouto

    I am not completely sure, but do you want to create the differentation of an Attribute: a_i - a_i-1. Try out the Differentiate operator from the time series operators. Deselect 'overwrite attributes' to create a new attribute containing the differentiated values.

    Best regards,
    Fabian
    User: "hugomsouto"
    New Altair Community Member
    OP
    I saw the solution and forgot to thank you, @tftemme, that was exactaly what I needed. So fast an easy, only took a previous sorting.

    Thanks @Telcontar120, you were almost on target. Thank you @jacobcybulski for all the efforts!