Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

remove last part of an ip-adress

chvizda
8 - Asteroid

Hi all

 

I hope you can help me out with following. I have IP adresses:

 

172.12.115.13

 

and I want to remove the last digits to have only

 

172.12.115.

 

The adress can be in any other format

 

10.10.10.10

1.1.1.1

192.168.150.1

...

 

Many thanks in advance

 

Steffen

4 REPLIES 4
patrick_digan
17 - Castor
17 - Castor

@chvizda I would use a regular expression like:

REGEX_Replace([Field1], "(.*)\..*","$1.")

I've attached a quick version 11.0 sample

chvizda
8 - Asteroid

works perfect. many thx

MarqueeCrew
20 - Arcturus
20 - Arcturus

Hold the presses @chvizda!  

 

I agree that @patrick_digan gave you a great solution.  If you like RegEx that is.  Did you know that RegEx is an expensive operation?  The timing for 10,000,000 records took me almost 20 seconds to process.  I used a non-RegEx solution and got to the same results in 8 seconds.

 

Left([field1],Length([field1])-(FindString(ReverseString([Field1]), ".")+1))

Granted, my formula is odd but here's a quick explanation.

  • Reverse the IP Address
  • Find the first (last) '.'
  • Add 1 (this is zero-based) to that location
  • Take the left-most characters from the input minus the total number of characters to that last '.'

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
patrick_digan
17 - Castor
17 - Castor

@MarqueeCrew I know some folks may not like it, but I truly love when the ReverseString formula can be used. I like your solution!

Labels
Top Solution Authors