I need a little help modifying an expression
Current Scenario
I have a data set that includes Name and cost type (CT) and amount for a given year (2017 $).
For any cost type Bs, I need to add B to A. (B is always negative.) I use the following expression with the Multi-Row Tool set to create new field.
if [Row+1:CT] = 'B' then [2017 $] + [Row+1:2017 $] else [2017 $] endif
Name | CT | 2017 $ |
Jeep | A | 555 |
G-Wagon | A | 1800 |
G-Wagon | B | -100 |
G-Wagon | C | 200 |
HMMWV | A | 800 |
HWMMV | B | -400 |
Unimog | A | 700 |
Question
Now I need to add E to the expression. Like B, E is always negative. But, its still A+B+E.
How do I mod the expression to include E?
Name | CT | 2017 $ |
Jeep | A | 555 |
G-Wagon | A | 1800 |
G-Wagon | B | -100 |
G-Wagon | E | -500 |
G-Wagon | C | 200 |
HMMWV | A | 800 |
HWMMV | B | -400 |
Unimog | A | 700 |
Solved! Go to Solution.
Okay, I tried the following...
if [Row+1:CT] = 'B' then [2017 $] + [Row+1:2017 $]
elseif [Row+1:CT] ='B' and [Row+2:CT] ='E' then [2017 $] + [Row+1:2017 $] + [Row+2:2017 $]
else [2017 $]
endif
It does not work with the"if" and "else if" expressions work on their own, BUT they don't work together. How do I do this?
I need to account for scenarios where just As exist, A and Bs exist and A, B and Es exist.
I think I got it. Hopefully it will translate to the real data/worklow.
if
[Row+1:CT] = 'B' and [Row+2:CT]!='E' then [2017 $] + [Row+1:2017 $]
elseif
[Row+1:CT] ='B' and [Row+2:CT] ='E' then [2017 $] + [Row+1:2017 $] + [Row+2:2017 $]
else [2017 $]
endif