Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
hmarek14
Level I

Difference in same column of numbers with a formula

Hi! I am new to jmp and I have a big data set I am working with, and I need to be able to calcuate the difference to help find rainfall for every 15 minutes during the day, the rainful is given in a column that sums it up daily. I have tried doing an if statement, but it seems to be ignoring the second line of code.

 

Ex:

Daily rain

12:00 AM .01

12:15 AM .03

12:30 AM .07

1 AM .09

 

I need my new column to say

Rainfall

.01

.02

.04

.02

 

It starts with if the time contains 12:00 AM then dailyrain = dailyrain.

What should the next time be?

2 REPLIES 2
Highlighted
uday_guntupalli
Level VIII

Re: Difference in same column of numbers with a formula

@hmarek14 ,
       Try the following column formula: 

If( Row() == 1,
	:rain,
	:rain[Row()] - Lag( :rain)
)
Best
Uday
Highlighted

Re: Difference in same column of numbers with a formula

The previous solution is correct but subscripting the current row is unnecessary as the formula is evaluated row-wise. Specifically,

 

If( Row() == 1,
	:Rain,
	:Rain - Lag( :Rain )
)
Learn it once, use it forever!
Article Labels

    There are no labels assigned to this post.