Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
suzel404
Creator
Creator

How to transform multiple fields in one ?

Hi all,

I have a table like this:

Load

     *,

     FLAG_1,

     FLAG_2,

     FLAG_3,

     FLAG_4

     FLAG_7

     FLAG_8

     FLAG_10

FROM QVD;

I want to transform all FLAG_ in one field FLAG like FLAG contains values : {1,2,3,4,7,8,10}

How can I realize it ?

Thanks for your help

Regards,

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe you want to look into the CROSSTABLE LOAD prefix:

CROSS:

CROSSTABLE (FlagName, FlagValue)

LOAD 

     Recno() as RecID,

     FLAG_1,

     FLAG_2,

     FLAG_3,

     FLAG_4,

     FLAG_7,

     FLAG_8,

     FLAG_10

   INLINE [

     FLAG_1,     FLAG_2,     FLAG_3,     FLAG_4,     FLAG_7,     FLAG_8,     FLAG_10 

     1,0,1,1,0,0,1

   ];

  

RESULT:

LOAD RecID, SubField(FlagName,'_',2) as Flag, FlagValue

RESIDENT CROSS;

DROP TABLE CROSS;

The Crosstable Load

View solution in original post

3 Replies
swuehl
MVP
MVP

Maybe you want to look into the CROSSTABLE LOAD prefix:

CROSS:

CROSSTABLE (FlagName, FlagValue)

LOAD 

     Recno() as RecID,

     FLAG_1,

     FLAG_2,

     FLAG_3,

     FLAG_4,

     FLAG_7,

     FLAG_8,

     FLAG_10

   INLINE [

     FLAG_1,     FLAG_2,     FLAG_3,     FLAG_4,     FLAG_7,     FLAG_8,     FLAG_10 

     1,0,1,1,0,0,1

   ];

  

RESULT:

LOAD RecID, SubField(FlagName,'_',2) as Flag, FlagValue

RESIDENT CROSS;

DROP TABLE CROSS;

The Crosstable Load

Anonymous
Not applicable

Hi Joshua,

you can concatenate the Flag values (&) ,  in order to get {1,2,3,4,7,8,10} try this:

Load

     *,

     '{ ' &FLAG_1 &' ,' & FLAG_2 &' ,' & FLAG_3 &' ,' & FLAG_4 &' ,' &   FLAG_7 &' ,' & FLAG_8 &' ,' & FLAG_10& '}'  as Flag

FROM QVD;

You can also change the name of the new field by changing "Flag" after "as"

I hope that helps!

suzel404
Creator
Creator
Author

thanks swuehl !

it was exactly what I need.