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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

Add and remove Fields inside column

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.

9 Replies
rubenmarin

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

nareshthavidishetty
Creator III
Creator III
Author

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.

maxgro
MVP
MVP

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;



1.png

nareshthavidishetty
Creator III
Creator III
Author

O/P is like:Store  Sales

           A       300

           C        300

           D        400

nareshthavidishetty
Creator III
Creator III
Author

Thanks Maxgro it's working fine, but I want to rename A+B as B.

jagan
Partner - Champion III
Partner - Champion III

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.

maxgro
MVP
MVP

change the final load

final:

load if(Store='A+B','B',Store) as Store, Sales, rowno() as id Resident source where Store <> 'B';

1.png

nareshthavidishetty
Creator III
Creator III
Author

I need to add A+B and then remove B

jagan
Partner - Champion III
Partner - Champion III

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.