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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

creating new field in script

Hi All,

I need some help creating a new field in the script.

I want to craete a 'Parent Pack Size' field. here is an example of data.

Parent Code                Variant Code             Pack Size

1000                            5241                         Single

1000                            1000                         24

1000                             5277                        12

2954                             3322                         6

2954                             2411                        single

2954                             2954                        18

So i want to create a new field which just holds the parent code pack sizes (the parent code is where the parent and variant code match)

Can anyone help me please?

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

if([Parent Code]=[Variant Code],[Pack Size]) as [Parent Pack Size]

This will create a new field, but it will only have a value for the records where Parent Code and Varian Code match. If you need all the records with the same Parent Code to have that value you need to do it with a join.

Table1:

Load * from ...somewhere...;

join load [Parent Code], [Pack Size] as [Parent Pack Size]

resident Table1

where [Parent Code]=[Variant Code];


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

if([Parent Code]=[Variant Code],[Pack Size]) as [Parent Pack Size]

This will create a new field, but it will only have a value for the records where Parent Code and Varian Code match. If you need all the records with the same Parent Code to have that value you need to do it with a join.

Table1:

Load * from ...somewhere...;

join load [Parent Code], [Pack Size] as [Parent Pack Size]

resident Table1

where [Parent Code]=[Variant Code];


talk is cheap, supply exceeds demand
manideep78
Partner - Specialist
Partner - Specialist

See this

temp:

LOAD * INLINE [

    ParentCode, VariantCode, PackSize

    1000, 5241, single

    1000, 1000, 24

    1000, 5277, 12

    2954, 3322, 6

    2954, 2411, single

    2954, 2954, 18

];

Join

LOAD  ParentCode,

      PackSize,

      If(ParentCode=VariantCode,PackSize) as ParentCodePackSizes

Resident temp;