Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Subfield function

Hi All,

I am using a field called Domiciled Country where the values are as below.

I want to get inly the country name. i.e. Afghanistan

In this scenario how to use Sub field function.

Domiciled Country
803;#Afghanistan
824;#Bhutan
825;#Bolivia

what I want is as below.

Domiciled Country
Afghanistan
Bhutan
Bolivia

Please advise.

Thanks

Ashish

1 Solution

Accepted Solutions
PrashantSangle

Hi,

Try like

subfield(Domiciled,'#',2)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

6 Replies
PrashantSangle

Hi,

Try like

subfield(Domiciled,'#',2)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
pokassov
Specialist
Specialist

Hello!

May be more easy way is using function PurgeChar?

q1:

load

PurgeChar(Country,'0123456789;#')     as CountryClear

Resident

Domiciled;

tobias_klett
Partner - Creator II
Partner - Creator II

Hi,

try this:

subfield([Domiciled Country],';',1) as DomiciledCountryCode,

subfield([Domiciled Country],'#',2) as DomiciledCountry

Hope this helps

Tobias

stigchel
Partner - Master
Partner - Master

Or try with SubField and alt function for when it's null in the first two cases, something like

Alt(subfield([Domiciled country],'#',2),[Domiciled country])

Not applicable
Author

Thanks Max for your quick response.

it's working as expected.

raghvendrasingh
Creator II
Creator II

Hi,

Please try the below script:

Tab1:

LOAD * INLINE [

   Country

    Domiciled

    Country

    803;#Afganistan

    824;#Bhutan

    825;#Bolvia

];

NoConcatenate

Tab2:

Load purgechar(Country,'0123456789;#') as Country Resident Tab1;

Drop table Tab1;