Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Gysbert_Wassenaar

LOAD

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

FROM

     ...


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

LOAD

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

FROM

     ...


talk is cheap, supply exceeds demand
Not applicable
Author

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

     ........

     ........

Gysbert_Wassenaar

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