Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to Cut String by Section

Hello Everybody,

I have a set of IP address such as:

IP
Address

IP1

255.01.01.01
IP2255.120.01.0
IP3155.10.01.02
IP455.02.03.123

I want to get data like this:

IP
Address
IP1225.01
IP2255.120
IP3155.10
IP455.02

Thanks in advance,

Dust

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try: left(Address,index(Address,'.',2)-1)


talk is cheap, supply exceeds demand

View solution in original post

8 Replies
Gysbert_Wassenaar

Try: left(Address,index(Address,'.',2)-1)


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you very much. Greatly appreciate.

Not applicable
Author

Hi Gysbert,

Thank you very much for your help. Real data is more complex than we can think.

I just find some data only go to level 2

IP
Address

IP1

255.01.01.01
IP2255.120.01.0
IP3155.10.01.02
IP4

55.02

So I need to add a '.' when load this data. Otherwise IP4 will not load.

I tried to load like this:

Load IP&'.' as IP FROM DB

Do you have any suggestion?

Thank you very much,

Dust

Not applicable
Author

try subField(Address,'.',1) &  '.' & subField(Address,'.',2)

Not applicable
Author

Thank you V4!

Your script works but when Address only have level 1 it will add '.' after.

IP
Address

IP1

255.01.01.01
IP2255.120.01.0
IP3155
IP4

55.02

to

IP
Address

IP1

255.01
IP2255.120
IP3155.
IP4

55.02

IP3 will followed by '.'

Thank you!

Not applicable
Author

if(index(Address,'.')=0,Address,subField(Address,'.',1) &  '.' & subField(Address,'.',2))

Not applicable
Author

the above should help

Not applicable
Author

Thank you very much --V4. I appreciate your solution. Do you think we can add a '.' to the string first? Then cut string by '.'?

Best regards,

Dust