turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Running Count of Repeated Values JSL Script?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 24, 2015 1:36 PM
(959 views)

I would like to script a running count or cumulative sum of repeated values within a column.

For example, first appearance should equal 1, max value of count by value specified should equal the cumulative sum of the value within the column.

color | count_color |
---|---|

RED | 1 |

RED | 2 |

BLUE | 1 |

YELLOW | 1 |

RED | 3 |

Ideally, the output for :count_color would not need the data table to be sorted by :color

Thanks.

3 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 24, 2015 4:24 PM
(408 views)

Try this expression in a column formula (or in a For Each Row() loop);

Eval**(**Eval Expr**(**Col Sum**(**Row**()** <= Expr**(**Row**())**, :color**)))**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 25, 2015 7:33 AM
(408 views)

Using the Eval command under formula generates an output, but all values = 0

Perhaps I have misinterpreted. My column formula is below.

// Running Count

New Column("count_color",

numeric,

continuous,

formula(

Eval(Eval Expr(Col Sum(Row() <= Expr(Row()), :color)))

)

);

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 26, 2015 10:55 AM
(408 views)

Either paste the formula from **MS** into the formula editor or wrap the formula in ** NameExpr** (longer explanation here):

New Column( "count",

Numeric,

"Continuous",

Format( "Best", 12 ),

Formula( Name Expr( Eval( Eval Expr( Col Sum( Row() <= Expr( Row() ), :color ) ) ) ) )

),

There is a bug in JMP that you've helped uncover; the resulting table does not include the Name Expr( ) wrapper around the formula when the table's <<getscript command is used. Thanks!

Craige