Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

XML node content

Hi

I have the following XML section:

<component>

     <section>

          <code code="S006" codeSystem="2.16.840.1.113883.4.292.30.14.1.2" displayName="Comentarios adicionales" />

          <title>COMENTARIO SOBRE EL ESTUDIO</title>

     </section>

</component>

and I am reading the attribute (code="S004") using LOAD:


LOAD

  code as Post_Score

FROM [lib://NEW/*.xml](XmlSimple, embedded labels, table is [component/section/code])

WHERE displayName='Comentarios adicionales';

I want to load the letter 'A' instead of "S004". (load 'A' whenever I read "S004)

How can I do that?

1 Solution

Accepted Solutions

Re: XML node content

LOAD

     If(code='S004','A',code) as Post_Score

FROM

     ...


talk is cheap, supply exceeds demand
3 Replies

Re: XML node content

LOAD

     If(code='S004','A',code) as Post_Score

FROM

     ...


talk is cheap, supply exceeds demand
Not applicable

Re: XML node content

Thanks a lot Gysbert.
What if I need to add several if statements for several possibilities?

For example: 


     If(code='S004','A',code) as Post_Score

     If(code='S003','B',code) as Post_Score

     ........

     ........

Re: XML node content

You can nest if statements:

if(code='S004','A',if(code='S003','B',code)) as Post_Score

You can use a pick-match combination:

pick(1+match(code, 'S004','S003', ...etc... ), code, 'A', 'B', ...etc) as Post_Score

And if you have a lot of codes to replace you can use a mapping table and the applymap function:

mapCodes:

MAPPING LOAD * INLINE [

Old, New

S004, A

S003, B

...etc

];

TableA:

LOAD

     ApplyMap('mapCodes', code) as Post_Score,

     ...etc

FROM

     ...


talk is cheap, supply exceeds demand
Community Browser