Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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];
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];
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;