cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

line selection

hcarr01
Level VI

I am looking for how to select the rows whose penultimate digit is 4, for example select the row which has the value "235 4 6"

This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User


Re: sélection de lignes

Here is a simple example that selects the rows where the penultimate digit is 4

txnelson_0-1678289510224.png

Names Default To Here( 1 );
dt = New Table( "hcarr01",
	add rows( 100 ),
	New Column( "example", set each value( Random Integer( -1000, 1000 ) ) )
);

// This is the selection statement to select the rows whose penultimate digit is 4
dt << select where( Substr( Char( :example ), -2, 1 ) == "4" );
Jim

View solution in original post

3 REPLIES 3


Re: sélection de lignes

One way to do this would be to grab the left-most digit of the right-most 2 digits, then see if it is 4. Then, select the rows where this formula returns a 1. Sample table attached.

Jed_Campbell_0-1678289110558.png

 

txnelson
Super User


Re: sélection de lignes

Here is a simple example that selects the rows where the penultimate digit is 4

txnelson_0-1678289510224.png

Names Default To Here( 1 );
dt = New Table( "hcarr01",
	add rows( 100 ),
	New Column( "example", set each value( Random Integer( -1000, 1000 ) ) )
);

// This is the selection statement to select the rows whose penultimate digit is 4
dt << select where( Substr( Char( :example ), -2, 1 ) == "4" );
Jim
Craige_Hales
Super User


Re: sélection de lignes

It's good to have choices. Here's one that avoids the string conversion.

dt << select where( 40 <= Mod( Abs( :example ), 100 ) < 50 );

You might prefer one of the others that uses conversion to string because...well, if Jim hadn't included negative numbers, I'd have left out the abs(...).

 

@DonMcCormack - challenge!

Craige