Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create a New Variable from part of another string variable?

Basically I have a variable that is a URL. Sometime it starts with http://. Other times it will start with https:// or www.

I basically want to create a Host Name variable from the URL variable.

So

http://hostone/addtexthere

http://hostone/moretextstuff/here

www.hostone/text/morestuff

http://hosttwo/stuff/here

The top three would be put classified as the same Host Name (Host One) based on the "hostone." The bottom one would be put in Host Name (Host 2) based on the part of it that says "hosttwo"

I am very much unsure how to go about this in Qlikview. Can anyone help me out here?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Let me try another way:

'Host ' & capitalize(textbetween(URL, 'host', '/'))

View solution in original post

7 Replies
Anonymous
Not applicable
Author

can you give example what should be stored in your new variables?

hostone\...

hosttwo\...

??

did you check the stringfunctions. they may help you

if you explain the outcome, it's easier to get help

marcus_malinow
Partner - Specialist III
Partner - Specialist III

try this substituting in your URL

subfield([Your URL], '/', 3)

Anonymous
Not applicable
Author

Assuming the URL always contains either hostone or hosttwo:

if(index(URL,'hostone'), 'Host One', 'Host Two')

Not applicable
Author

Basically what I want stored in my new variable would just be the host name. So the part that is after the www. but before any of the slashes.

So for the example I gave above I would want hostone and hosttwo to be what is stored in the new variable.

Not applicable
Author

Yeah, I used hostone and hosttwo as a basic example, but with the data I'm working with I will likely have over 40 hosts.

Anonymous
Not applicable
Author

Let me try another way:

'Host ' & capitalize(textbetween(URL, 'host', '/'))

Not applicable
Author

Thank you, I'm a new user and was unaware of the textbetween() function! This worked perfectly for what I wanted, thank you!