Calculate difference from row values instead columns

Hi All

How can i Calculate difference from row values instead columns. Below is the example

Below Data is available in csv file

Month Amount Type Value
Jan Type A 150
Jan Type B 100
Jan Type C 20
Feb Type A 200
Feb Type C 20
Feb Type B 100

Now I want to calculate difference in Jan and Feb month for Type A and Type B amount Type and the expected result is

Month Type Difference
Jan Type A 50
Feb Type B 0

This come with the calculation
In Jan and Feb Type A value is 150 and 200 and its variance with respect to Jan is (200-150)=50

Similarly
In Jan and Feb Type B value is 100 and 100 and its variance with respect to Jan is (100-100)=0

How can i achieve this ?

i tried something using ruby filter and transpose the data, with that also no luck.
I think i am missing something here,if this would have been sql query we would have added the Amount type as filter and do the difference, how we will achieve this with pipeline

Take a look at the aggregate filter. Your use case is similar to example 1.

Aggregate based on Amount Type. For Jan, do the task start and save the value in the map (and drop the event). For Feb calculate the difference by retrieving the Jan value from the map and then event.set the difference, and set end_of_task.

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