Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

meizheng
New Contributor III

Subfield returns first value only

Hi all,

I have an Application field that has either one or more than one Application name. I use a replace to get ride of any spaces. The App names are separated by a comma. My code is as follows:

if(isNull(Application),'NIL', if(Application like '*,*',

        Replace(Subfield("Application",','),' ', ''), Replace(Application, ' ', '')))

The problem is with a value like "App A, App B - XXX, App C - XXX"

The desired result would be like so:

Application...
AppA...
AppB-XXX...
AppC-XXX...

However I am getting only AppA

Application...
AppA...
AppA...
AppA...

Any ideas on how I can achieve this splitting?

Update: Am able to split the Application names correctly, it is when linked with another table that only the first Application name appears in the straight table.

Thanks.

Best Regards

Serena

5 Replies
omarbensalem
Esteemed Contributor

Re: Subfield returns first value only

try this:

load subfield(trim(test),',') as test;

result:

Capture.PNG

devarasu07
Honored Contributor II

Re: Subfield returns first value only

Hi,

can you share your mock  source data?

also u can try like this (it should work if your application value within double quote)

Fact:

load *, SubField(Application,',') as Application_Revised;

load * Inline [

Application

"AppA,AppB-XXX,AppC-XXX"

];

omarbensalem
Esteemed Contributor

Re: Subfield returns first value only

he has to eliminate spaces in his string before using subfield;

load subfield(trim(Application),',') as Application;

meizheng
New Contributor III

Re: Subfield returns first value only

Hi,

Using mock data both fields is correct

testAppTable:

LOAD

if(Application like '*,*',

        Subfield(Replace(Application, ' ', ''), ','),

            Application) as App,

subfield(trim(Application),',') as test,

Application as testApplication,

Subfield(Application, ',') as testSF;

Load * inline [

Application

'AppA,AppB-XXX,AppC-XXX'

'C&S'

];

Am thinking when linked with my report table, somehow only the first App name is kept...

kaanerisen
Contributor III

Re: Subfield returns first value only

Hi,

test:

load

header,

subfield(replace(value,' ',''),',') as result

Inline

[header,value

1,'App A, App B - XXX, App C - XXX'

];

Untitled.png