Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Changing value in column on the load script

I have the following load

LOAD

    Subject,

    "Override Flag",

    num(Grade) as Grade,

    "School Performance School Flag",

     "Attributed District Name"

 

FROM [my file]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq)

WHERE MATCH ("Subject",'M', 'R','E' ,'S')

and ("Attributed District Name"='PHILADELPHIA CITY SD')

and ("School Performance School Flag"='Y')

and ("Grade"<'11')

;

I want to change the value of the Subject so that instead of M I get math and instead of R I get reading. Any help is appreciated it. I am thinking of using an if statement, but I am not sure where I should put it on the Load script. Thanks for any help provided.

3 Replies
maxgro
MVP
MVP

LOAD

    Subject,

    if(Subject = 'M', 'math',

    if(Subject = 'R', 'reading',

    Subject
    )) as Subject,

    "Override Flag",

    num(Grade) as Grade,

    "School Performance School Flag",

     "Attributed District Name"

FROM [my file]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq)

WHERE MATCH ("Subject",'M', 'R','E' ,'S')

and ("Attributed District Name"='PHILADELPHIA CITY SD')

and ("School Performance School Flag"='Y')

and ("Grade"<'11')

;

Anonymous
Not applicable
Author

Using if's then maybe something like this

LOAD

    if ( Subject = 'M', 'math' ,

    if ( Subject = 'R' , 'reading' , Subject ) ) as Subject ,

    "Override Flag",

    num(Grade) as Grade,

    "School Performance School Flag",

    "Attributed District Name"

..................


kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can try if statement as below.

LOAD

    Subject,

If(Subject='R','Reading,

     if(Subject='M','XYZ')) as NewSubject,

    "Override Flag",

    num(Grade) as Grade,

    "School Performance School Flag",

     "Attributed District Name"

FROM [my file]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq)

WHERE MATCH ("Subject",'M', 'R','E' ,'S')

and ("Attributed District Name"='PHILADELPHIA CITY SD')

and ("School Performance School Flag"='Y')

and ("Grade"<'11')

;

Or you can use the Apply Map as Below.

Map:

Load * inline [

X,Y

R,Reading

M,XYZ

];

LOAD

    Subject,

Applymap('Map',Subject) as NewSubject,

    "Override Flag",

    num(Grade) as Grade,

    "School Performance School Flag",

     "Attributed District Name"

FROM [my file]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq)

WHERE MATCH ("Subject",'M', 'R','E' ,'S')

and ("Attributed District Name"='PHILADELPHIA CITY SD')

and ("School Performance School Flag"='Y')

and ("Grade"<'11')

;

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!