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
- :
- Comparing row values

- 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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 14, 2018 2:20 PM
(2162 views)

I have a table which has 2 columns Term and Multiply which looks something like this:

I want to somehow be able to read the column "Term" and check the following:

1) If the term in the "Term" column is not multiplied by anything (like Name, Place, Animal and Thing in the above table), then multiply the value in the "Multiply" column by 2.

2) If the term in the "Term" column is multiplied by any other term (like Place*Thing in the above table), then multiply the value in the "Multiply" column by 2.

3) If the term in the "Term" column is multiplied by itself(like Name*Name and Animal*Animal in the above table), then keep the value in "Multiply" column as it is.

The resulting table would look like this:

Can this be done using jsl? Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

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

Maybe something like this:

```
New Table( "Multiply",
Add Rows( 8 ),
New Column( "Term", Character, "Nominal",
Set Values( {"Name", "Place", "Animal", "Thing", "Name*Name", "Place*Thing",
"Animal", "Animal*Animal"} )
),
New Column( "Multiply", Numeric, "Continuous",
Format( "Best", 12 ),
Set Values( [0.43, 0.5567, 0.056, 0.236, 0.15503, 0.44479, 0.7789, 0.22754] )
),
New Column( "Result",
Expression,
"None",
Formula(
mtch = Regex Match( :Term, "([^*]*)\*([^*]*)" );
If(
N Items( mtch ) == 0, :Multiply * 2,
N Items( mtch ) == 3,
If( mtch[2] == mtch[3],
:Multiply,
:Multiply * 2
)
);
)
)
)
```

2 REPLIES 2

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

Re: Comparing row values

deleted my response because I realized I didn’t answer the right question

-- Cameron Willden

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

Maybe something like this:

```
New Table( "Multiply",
Add Rows( 8 ),
New Column( "Term", Character, "Nominal",
Set Values( {"Name", "Place", "Animal", "Thing", "Name*Name", "Place*Thing",
"Animal", "Animal*Animal"} )
),
New Column( "Multiply", Numeric, "Continuous",
Format( "Best", 12 ),
Set Values( [0.43, 0.5567, 0.056, 0.236, 0.15503, 0.44479, 0.7789, 0.22754] )
),
New Column( "Result",
Expression,
"None",
Formula(
mtch = Regex Match( :Term, "([^*]*)\*([^*]*)" );
If(
N Items( mtch ) == 0, :Multiply * 2,
N Items( mtch ) == 3,
If( mtch[2] == mtch[3],
:Multiply,
:Multiply * 2
)
);
)
)
)
```