Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Filter between 2 numbers

MKAJ786
6 - Meteoroid

Hi, I'm fairly new to Alteryx. I have data that has a column with postal codes and I want to filter these code between a particular range, lets say from 1000 to 2500. I wrote the expression in the Filter Tool as:

 

[Postal Code] > "1000" AND [Postal Code] < "2500". This doesn't seem to work as it gives me ALL values below 2500.

7 REPLIES 7
jdunkerley79
ACE Emeritus
ACE Emeritus

Looking at your sample you are doing a string comparison. This means Alteryx is doing an alphetical check not a numerical check try:

 

ToNumber([Postal Code]) > 1000 AND ToNumber([Postal Code]) < 2500

or better still use a Select tool to change the type of [Postal Code] to an Int32 and then

 

[Postal Code] > 1000 AND [Postal Code] < 2500

will work

JordanB
Alteryx
Alteryx

Hi @MKAJ786

 

I am struggling to replicate that behavior (attached workflow shows the correct results) 

 

In the workflow I have made sure I tested with both string and numeric data types. Both provide the same results, but if your postcodes are all numbers I would suggest making sure the data type is numeric before passing into the filter tool, as you are looking for a range.

 

Best,

 

Jordan Barker

Solutions Consultant  

 

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

try this please:

 

ToNumber([Postal Code]) > 1000 AND ToNumber([Postal Code]) < 2500

 

Thanks,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
JessicaS
Alteryx Alumni (Retired)

Good Morning Everyone,

 

I've merged two threads together on this post, looks like @MKAJ786's original post accidentally got duplicated.

 

Thanks!

Jess Silveri
Manager, Technical Account Management | Alteryx
jdunkerley79
ACE Emeritus
ACE Emeritus

 

@JordanB

 

With a string data type, the initial expression would include "240" as this is greater than "1000" and less than "2500"

 

Thats my guess of the scenario seen.

James

MKAJ786
6 - Meteoroid

Hey. This worked for me. THANK YOU!

JordanB
Alteryx
Alteryx

@jdunkerley79 good spot I should have realized that!

 

Best,

 

Jordan

Labels