How to create an attribute with the difference

hugomsouto
New Altair Community Member
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!
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!
Tagged:
0
Best 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,
Fabian2
Answers
-
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)
2 -
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
1 -
Have you tried the Lag operator from the Time Series group of operators?
2 -
Great idea @Telcontar120 in which case we do not need to make this awkward duplication and merging of out of sync example sets.
1 -
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,
Fabian2 -
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!1