Compute a mathematical operation depending on the row value

I have a dataframe with many variables, but I want to focus on two of them:

Time   | Value
Start     200
1         50
2         50
4         50
8         50
12        80
24        80
Start     300
1         50
2         50
4         50
8         50
12        60
24        70
Start     250

These columns represent the value for a given time.

I want to obtain another column that represents the difference in value between a given time and the start.

To make it clear, I would like something like:

Time   | Value   |  Change
Start     200         200
1         50          150
2         50          150
4         50          150
8         50          150
12        80          120
24        80          120
Start     300         300
1         50          250
2         50          250
4         50          250
8         50          250
12        60          240
24        70          230
Start     250         250

So it’s a simple mathematical operation.

However, the tricky part is to compute always against the last start value, and I haven’t find a way of doing this so far.

Any help is highly appreciated.

You haven’t really given us much to work with.

Assuming the rows under investigation are always chunks of 7, the following approach can work:

image

image

image

image

4 Likes

Without loop or for uneven chunks:

Rule Engine [Base]:
$Start$ LIKE "Start" => $Value$

Missing Value [Base]:
Previous Value

Math Formula [Change]:
if($Base$ == $Value$, $Value$, $Base$-$Value$)

BR

4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.