- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Comparing row values
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Comparing row values
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
)
);
)
)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Comparing row values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Comparing row values
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
)
);
)
)
)