Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
polisetti
Creator II
Creator II

Overwriting a field in Script

Hi,

I have a script like below

Load

     src,

     id,

     flag

From a.qvd

now the data is like this

SourcIDFLAG
AT11
BT11
CT11
CT21

Here I want to change the flag to 0 for souce C and id= T2, T3, T4 so on.

and rest of the entries should remain same.


Please suggest

8 Replies
sujeetsingh
Master III
Master III

You can use id conditions to quote it as

=If(Source='C',Flag=0) like this

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Load

     src,

     id,

     If(src = 'C' And Match(id,'T2', 'T3', 'T4'), 0, flag) as flag

From a.qvd

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
MK_QSL
MVP
MVP

Load

  Source,

  ID,

  IF(Source = 'C' and (ID = 'T2' or  ID = 'T3' or ID = 'T4'), 0, Flag) as Flag

Inline

[

  Source, ID, Flag

  A, T1, 1

  B, T1, 1

  C, T1, 1

  C, T2, 1

];

VishalWaghole
Specialist II
Specialist II

Hi,

Try this,

LOAD Sourc,

     ID,

     FLAG,

     if(match(Sourc,'C') and match(ID,'T2','T3','T4'),0, FLAG) as FLAG1

FROM

[http://community.qlik.com/thread/128622]

(html, codepage is 1252, embedded labels, table is @1);

-- Regards,

Vishal Waghole

ashfaq_haseeb
Champion III
Champion III

Try below

=If(Source='C' and (ID=T2 or ID=T3 or ID =T4),Flag=0)


Regards

ASHFAQ

crusader_
Partner - Specialist
Partner - Specialist

Hi,

Load

     src,

     id,

     if(WildMatch(src,'C')=1 and WildMatch(id,'T1')=0, flag=0, flag) as flag

From a.qvd

HTH

Andrei

polisetti
Creator II
Creator II
Author

Actually the number of ids for which flag has to be overwritten is to be dynamic.

Have a variable tht is calculated and gives a value in the range of 2 or 3.

if variable = 3

then t4, t3, t2 flags are to be made 0.

If variable = 2

then t4, t3 flags are to be made 0. Please help

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

Use this variable.

if($(variable) = 3, match(Sourc,'C') and match(ID,'T2','T3','T4'),0,

if($(variable) = 2, match(Sourc,'C') and match(ID,'T3','T4'),0,Flag)) as New_Flag

Regards,

Kaushik Solanki


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