cancel
Showing results for 
Search instead for 
Did you mean: 

Filter between 2 numbers

SOLVED
MKAJ786
Atom

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.

  • Alteryx Designer
  • Common Use Cases
  • Preparation
Magnetar
Magnetar

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

Highlighted
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  

 

 

Alteryx Certified Partner
Alteryx Certified Partner

try this please:

 

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

 

Thanks,

Mark

ACE & Alteryx Certified Partner
Chaos reigns within. Repent, reflect and reboot. Order shall return.
Moderator
Moderator

Good Morning Everyone,

 

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

 

Thanks!

Jessica Silveri
Customer Support Engineer
Magnetar
Magnetar

 

@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
Atom

Hey. This worked for me. THANK YOU!

Alteryx
Alteryx

@jdunkerley79 good spot I should have realized that!

 

Best,

 

Jordan