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

loading script question

Hi all,

is it possible to put an instruction in the loading script in order to change some information in the data?

For example, I have these columns MRC, CIRCUIT and COUNTRY, and I know I have an issue with the DB I am using and I would like to give this kind of instruction:

where the CIRCUIT name is ending with 5 and the COUNTRY is Spain , replace the value in the column MRC with 10.

Is it possible?

Many thanks in advance

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like

LOAD

     If( CIRCUIT Like '*5' and COUNTRY ='Spain', 10, MRC) as MRC,

     CIRCUIT,

     COUNTRY

FROM ....;

View solution in original post

10 Replies
swuehl
MVP
MVP

Maybe like

LOAD

     If( CIRCUIT Like '*5' and COUNTRY ='Spain', 10, MRC) as MRC,

     CIRCUIT,

     COUNTRY

FROM ....;

marikabi
Creator
Creator
Author

It is working

and what if I need to add more conditions like this one for the same field?

swuehl
MVP
MVP

Just add them... as long as all information originate from within the same record, it should be quite easy.

marikabi
Creator
Creator
Author

Thank you Stefan,

you were really helpful

vishsaggi
Champion III
Champion III

Just use Match or Wildmatch in your IF as suggested by Stefan.

You can also use like

IF(Wildmatch(CIRCUIT, '*5', '*8', '*2') AND Match(COUNTRY, 'Spain', 'Swedan'), 10, MRC) AS MRC

marikabi
Creator
Creator
Author

Hi,

thank you for your answer

what now I need to do is to add more conditions, on the same fields but on different records and replacing the wrong data with different information.

Using your example, what if I want to use for Sweden 15, and instead of CIRCUIT the STATUS?

swuehl
MVP
MVP

Are you looking for something like

LOAD

     If( CIRCUIT Like '*5' and COUNTRY ='Spain', 10,

          If(STATUS Like '*5' and COUNTRY = 'Sweden', 15, MRC)) as MRC,

     CIRCUIT,

     COUNTRY,

     STATUS

FROM ....;

But this can get quite messy if you are applying a lot of these if() statements.

marikabi
Creator
Creator
Author

Uhm, you are right, it is messy.. but I will not use more than 3 conditions

Thank you so much

vishsaggi
Champion III
Champion III

AS Stefan suggested you might have to use nested IF's using Match and wildmatch too.
BTW what is your complete requirement here?