Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi I have an issue like,
Store Sales
A 100
B 200
C 300
D 400
Her I need add two rows like (A+B) as B and then I need remove ‘B’.
Can anyone help me how to do this in detail.
Hi naresh, you can use a precedent LOAD to change the original data:
Data:
LOAD A,
A + B as A+B,
C,
D;
LOAD A,B,C,D From ...;
This ends with a table named Data and fields A, A+B, C and D
Thanks for your quick reply,
Here my columns are Store and Sales,in a store column i have a records like(A,B,C,D).
My requirement is ,i want to sum the A and B record after that i want to remove A record in Store Column.
in script you can
source:
load * inline [
Store Sales
A 100
B 200
C 300
D 400
] (delimiter is spaces);
load
'A+B' as Store,
sum(Sales) as Sales
Resident source
where Match(Store, 'A', 'B');
load * Resident source where Store = 'A+B';
final: load *, rowno() as id Resident source where Store <> 'B';
DROP Table source;
O/P is like:Store Sales
A 300
C 300
D 400
Thanks Maxgro it's working fine, but I want to rename A+B as B.
Hi Naresh,
Try like this
Data:
LOAD
If(Match(Store, 'A', 'B'), 'A', Store) AS Store
Sales
FROM DataSource;
Hope this helps you.
Regards,
Jagan.
change the final load
final:
load if(Store='A+B','B',Store) as Store, Sales, rowno() as id Resident source where Store <> 'B';
I need to add A+B and then remove B
Hi Naresh,
Try this script
Data:
LOAD
If(Match(Store, 'A', 'B'), 'A', Store) AS Store,
Sales
INLINE [
Store, Sales
A, 100
B, 200
C, 300
D, 400];
Hope this helps you. Using above script B is changed to A.
Regards,
Jagan.