Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
polisetti
Contributor

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

Tags (1)
8 Replies
sujeetsingh
Honored Contributor III

Re: Overwriting a field in Script

You can use id conditions to quote it as

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

MVP
MVP

Re: Overwriting a field in Script

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
MVP
MVP

Re: Overwriting a field in Script

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
Valued Contributor II

Re: Overwriting a field in Script

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

Re: Overwriting a field in Script

Try below

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


Regards

ASHFAQ

crusader_
Valued Contributor

Re: Overwriting a field in Script

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
Contributor

Re: Overwriting a field in Script

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

Re: Overwriting a field in Script

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


Community Browser