Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Accumulation of certain variables as other variable

Dear Community,

I've got following issue

Imagine following table structure

Table_ex.jpg

I want to create a new variable 'C4' in my loading script that accumulates the 'benefit'-values when variable 'Cat' has value 'C2' or 'C3'

The final result should look like this:

Table_result.jpg

I tried using if-statements, but never with the right result.

Thanks in advance for you help

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Something like this:

Load Site, if(Cat='C2' or Cat='C3', 'C4', Cat) as Cat, Benefit

from ...;

You can simply sum Benefit in an expression in the Front End. If you want to do that in the script you do it like this:

Load Site, if(Cat='C2' or Cat='C3', 'C4', Cat) as Cat, sum(Benefit) as Benefit

from ...

group by Site, Cat;


talk is cheap, supply exceeds demand

View solution in original post

1 Reply
Gysbert_Wassenaar

Something like this:

Load Site, if(Cat='C2' or Cat='C3', 'C4', Cat) as Cat, Benefit

from ...;

You can simply sum Benefit in an expression in the Front End. If you want to do that in the script you do it like this:

Load Site, if(Cat='C2' or Cat='C3', 'C4', Cat) as Cat, sum(Benefit) as Benefit

from ...

group by Site, Cat;


talk is cheap, supply exceeds demand