Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
mvs01
Contributor II
Contributor II

Subtract or add values with rows in data load editor

How can I subtract or add the values within rows in the data load editor?

For example:

AB
110.000
22.500

 

I would like to subtract 10.000 -/- 2.500 and then, add this value to row 3.

AB
37.500

 

Thanks in advance!

Labels (1)
3 Replies
Lauri
Specialist
Specialist

Try using the Previous() function. Make sure the load sorts the table correctly.

MayilVahanan

HI @mvs01 

Try like this.. 

Temp:
LOAD * INLINE [
A, B
1, 10.000
2, 2.500
];

Concatenate
LOAD * where not IsNull(A);
Load Previous(A)+A as A, Previous(B)-B as B Resident Temp;

Am not sure, what is ur exact requirement?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
mvs01
Contributor II
Contributor II
Author

Thanks everyone for the reply, now I can ask my question better. My requirement is as follows (another example).

I'm having this data:

AB
110000
22500
37500
43000

 

I would like to subtract the value where A = 1 with the value where A = 4 and then add the new value to a new row. Like this: row A = 5 and value = 10.000 -/- 3.000 = 7.000.

I found a workaround so far:

Temp:
LOAD * INLINE [
A, B
1, 10.000
2, 2.500

3, 7.500

4, 3.000

];

Concatenate:

LOAD
5 as A
- sum(If(A=1, B)) - sum(If(A=4, B)) as B
Resident Temp
Group By A;

Is this the way you would do? Any feedback would be welcome!

Thanks again!