We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Ends With

NBPSE
8 - Asteroid

What is the best way to select a number or string that 'ends with' the number 2?

3 REPLIES 3
ShashankLalwani
Alteryx
Alteryx

You can use the Filter Tool with a regular expression or a simple string function, depending on your data type

 

1. Filter tool with Right() function : RIGHT(TOSTRING([YourField]), 1) = "2".

(This checks if the last character of the field is "2") and great for straightforward cases.

 

2. Using the Filter Tool with REGEX_Match(2). REGEX_Match(TOSTRING([YourField]), ".*2$")

This matches any string that ends with the digit 2.Gives you more flexibility if your data might include letters, symbols, or varying formats

aatalai
15 - Aurora

To add to that you can also do it via the filter tool and use endswith([Yourfield],"2")

 

AlteryxTrev
10 - Fireball

You can do this a number of ways:

 

The most straightforward it to simple take the "Right 1" of the string like this:

Right([YourData],1) = "2".

 

You can also do this by reversing the string and then taking the "Left 1", like this:

Left(ReverseString([YourData],1) = "2".

 

In the event your data is not a string you can simply wrap your data field with ToString() to force it to be a string, like this:

Right(ToString([YourData]),1) = "2"

Left(ReverseString(ToString([YourData]),1) = "2"

 

If its helpful, I've also created a video response that shows the same thing: https://youtu.be/TjOS4U_W_0A

In this Alteryx Community Solve video, we walk through how to filter values that end in the number 2, whether they're stored as strings or integers. This question came from a real Alteryx Community post, and we show a few different methods to get the job done depending on the data type and setup ...
Labels
Top Solution Authors