Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add a flag in script

Hi,

I have a complex requirement in my project.

To put it in simple words I want to add a flag and repeat my Amount and TXN numbers based on a condition.

Below is my original script.

Table1:

LOAD * INLINE [

    Key, Flag

    1, Y

    2, N

    3, N

];

Table2:

LOAD * INLINE [

    Key,  Amount, TXN, Tier, Date

    1,     10,         1,       A,   5/12/2016

    2,     20,         2,       B,   3/12/2016

    2,     40,         2,       C,   3/12/2016

    3,     30,         3,       C,   1/12/2016

];

Now I want to insert a new Tier into Table2 called as 'D' .

And duplicate the records in table 2 when Flag = Y in Table 1.

Any help/sample code appreciated.

Thanks in advance.

Regards,

Roy

1 Solution

Accepted Solutions
sunny_talwar

Check out the attached script:

MappingTable1:

Mapping

LOAD * INLINE [

    Key, Flag

    1, Y

    2, N

    3, N

];

Table2:

LOAD *,

  ApplyMap('MappingTable1', Key) as Flag;

LOAD * INLINE [

    Key,  Amount, TXN, Tier, Date

    1,    10,        1,      A,  5/12/2016

    2,    20,        2,      B,  3/12/2016

    2,    40,        2,      C,  3/12/2016

    3,    30,        3,      C,  1/12/2016

];

Concatenate(Table2)

LOAD Key,

  Amount,

  TXN,

  Flag,

  'D' as Tier,

  Date

Resident Table2

Where Flag = 'Y';



View solution in original post

1 Reply
sunny_talwar

Check out the attached script:

MappingTable1:

Mapping

LOAD * INLINE [

    Key, Flag

    1, Y

    2, N

    3, N

];

Table2:

LOAD *,

  ApplyMap('MappingTable1', Key) as Flag;

LOAD * INLINE [

    Key,  Amount, TXN, Tier, Date

    1,    10,        1,      A,  5/12/2016

    2,    20,        2,      B,  3/12/2016

    2,    40,        2,      C,  3/12/2016

    3,    30,        3,      C,  1/12/2016

];

Concatenate(Table2)

LOAD Key,

  Amount,

  TXN,

  Flag,

  'D' as Tier,

  Date

Resident Table2

Where Flag = 'Y';