One Star

Difference between a column of Two Consecutive Rows

Hi ALL
I have an excel file in this format
NAme , Salary
asd , 122
sda, 124

I want to output an xml file where i have a node " difference"
this node has the value of salary of current row - salary of previous row

can some one guide me how i can take this difference between same column of two consecutive rows?
can i use some global variable? like i have idea that i can store the value of first salary in the global variable and then in coming nodes it will be just like Row1.Salary-variable and then i will update the variable= row1.salary so that i can use it for next node " Difference"

please guide

Steven
5 REPLIES
One Star

Re: Difference between a column of Two Consecutive Rows

Hi,
I don't have experience with this, but I think it can be done like this:
Make sure you have rownumber in your Excel file

tExcelInput1 -->
\
tMap --> someOutput
/
tExcelInput2 -->

The tExcelInput1 & tExcelInput2 should contain you Excel file
In the tMap create an "inner join" on the (rownumber -1)
If there is no rowNumber, I would consider loading the data to a databaseTable first.
Seven Stars

Re: Difference between a column of Two Consecutive Rows

Use tMemorizeRows to capture previous rows' values. You can then calculate the difference in tMap or tJavaRow. (Or you can do it all yourself in tJavaRow.)
That will be more efficient than reading the file twice and joining it.
One Star

Re: Difference between a column of Two Consecutive Rows

you can see the Official documentation on the use of tMemorizeRows, maybe it can help you
One Star

Re: Difference between a column of Two Consecutive Rows

Hi, i have scenario in which i want to check if the row is 1st row of excel then it will output same column value else it will
do calculation like current_col - previous_col and column contain only time!!!
i try to use tMemorize_Row and tExcel_Row_NB_Line (show number of lines after full file read rather than 1 by 1)both gives error !!!
Seven Stars

Re: Difference between a column of Two Consecutive Rows

asa436, you should create a new topic and give details of the errors you get and the configuration that's causing them.