cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
saitcopuroglu
Level IV

How to compare each row to the one before

Dear JMP users/developers,

I have a data set and I would like to compare the increase/decrease in percentages for each column by year

Let's say I would like to know the percentage of RoomNight change compared to the year before.

Could any one please tell me the formula for it?

Many thanks in advance

9649_2015-08-25_12-33-42.png

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to compare each row to the one before

You can use the Lag() function. For example:


New Column("Annual Change",

    Numeric,

    Format("Percent", 12, 1),

    Formula(If(Row() != 1, ((:Room Night - Lag(:Room Night, 1)) / Lag(:Room Night, 1))))

);

View solution in original post

4 REPLIES 4
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to compare each row to the one before

You can use the Lag() function. For example:


New Column("Annual Change",

    Numeric,

    Format("Percent", 12, 1),

    Formula(If(Row() != 1, ((:Room Night - Lag(:Room Night, 1)) / Lag(:Room Night, 1))))

);

saitcopuroglu
Level IV

Re: How to compare each row to the one before

Thank you!

saitcopuroglu
Level IV

Re: How to compare each row to the one before

Thank you again and what is the logic of Lag() when comparing all years to the first year or second (or any selected year)?

Lets say I would like to compare the Room Night inc/dec to the 2007 or 2013?

Many many thanks for your support.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to compare each row to the one before

Lag() always refer to a row relative to the current row. To compare with a fixed reference year it may be easier to use an index. Lag() can also be used but would require that the data is regular with no missing years.

// Using a fixed index, assuming 2007 in first row

New Column("Change since 2007",

    Numeric,

    Format("Percent", 12, 1),

    Formula((:Room Night - :Room Night[1]) / :Room Night[1])

);

// The same using lag (assuming there are no missing years)

New Column("Change since 2007_2",

    Numeric,

    Format("Percent", 12, 1),

    Formula((:Room Night - Lag(:Room Night, :Year[Row()] - 2007)) / Lag(:Room Night, :Year[Row()] - 2007))

);

Recommended Articles