Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Live chat with experts, bring your API Integration questions. June 15th, 10 AM ET. REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

String Function

Is there a string function to convert my string of type servername.na.corp.companyname to servername.

I have to delete the .na.corp.companyname part.

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

What are you expecting to return for a number? the whole number string if its a number?

So maybe try:

=if(isnum(Subfield(YOURFIELD, '.',1)), YOURFIELD, Subfield(YOURFIELD, '.',1))

For 10.32.123.45, this will just return 10.32.123.45. For servername.na.corp.companyname, servername.

Hope this helps!

View solution in original post

10 Replies
jerem1234
Specialist II
Specialist II

=Subfield('servername.na.corp.companyname', '.',1)

Hope this helps!

Not applicable
Author

Hi,

I think subfield can do that job (but there will be other ways as well).

subfield(s, 'delimiter' [ , index ] )

In its three-parameter version, this script function returns a given substring from a larger string s with delimiter

'delimiter'. index is an optional integer denoting which of the substrings should be returned. If index is

omitted when subfield is used in a field expression in a load statement, the subfield function will cause the

load statement to automatically generate one full record of input data for each substring that can be found in

s.

In its two-parameter version, the subfield function generates one record for each substring that can be taken

from a larger string s with the delimiter 'delimiter'. If several subfield functions are used in the same load

statement, the Cartesian product of all combinations will be generated.

Examples:

subfield(S, ';' ,2) returns 'cde' if S is 'abc;cde;efg'

Regards,

Gerrit

Not applicable
Author

Thanks a lot for your quick response... It worked really well expect for some servernames are in numeric form and I want them not to change For Example : 10.32.123.45 ... So by using the previous function it is returning me just 10 but that is not intended !!... How do I go around this??

Not applicable
Author

Thanks a lot for your quick response... It worked really well expect for some servernames are in numeric form and I want them not to change For Example : 10.32.123.45 ... So by using the previous function it is returning me just 10 but that is not intended !!... How do I go around this??

dagomezl
Creator III
Creator III

Subfield('servername.na.corp.companyname', '.',1)

&'.'&

Subfield('servername.na.corp.companyname', '.',2)

&'.'&

Subfield('servername.na.corp.companyname', '.',3)

&'.'&

Subfield('servername.na.corp.companyname', '.',4) as ServerName

jerem1234
Specialist II
Specialist II

What are you expecting to return for a number? the whole number string if its a number?

So maybe try:

=if(isnum(Subfield(YOURFIELD, '.',1)), YOURFIELD, Subfield(YOURFIELD, '.',1))

For 10.32.123.45, this will just return 10.32.123.45. For servername.na.corp.companyname, servername.

Hope this helps!

View solution in original post

Clever_Anjos
Employee
Employee

na.corp.companyname is always fixed?

If yes

=left('10.32.123.45.na.corp.companyname',index('10.32.123.45.na.corp.companyname','.na.corp.companyname')-1)

jerem1234
Specialist II
Specialist II

I think I read your post too fast,

If your string looks like 10.32.123.45.na.corp.companyname, then try:

=if(isnum(Subfield(YOURFIELD, '.',1)), left(YOURFIELD, 12), Subfield(YOURFIELD, '.',1))

This assumes the same amount of characters for your numeric representation of your server, if your string is not always 12 characters long, this won't work.

Hope this helps!

Not applicable
Author

This worked.. thanks...