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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to sum 2 dept from a column and other dept individually in load script

Here I have 2 columns  where ever i have MKT and MGT in DEPT column these both need to summed together and other deparments need to summed individually  it should be written in load script only.

DEPT SALARY

  MKT 33500
  MGT 45000

  LIB 22000
  RND 27500
  FIN 42000

output should be
salary

   78500(MKT+MGT)
   22000 (LIB)
   27500 (RND)
   42000 (FIN)

If any suggestions kindly help

5 Replies
shraddha_g
Partner - Master III
Partner - Master III

In Load script create new Dept as

If (wildmatch(Dept,'MKT','MGT'),'MKT+MGT',Dept) as New_Dept

Not applicable
Author

I  need the sum salary of those 2 departments and other departments individually

salary

   78500  (MKT+MGT)
   22000  (LIB)
   27500 (RND)
   42000 (FIN)

shraddha_g
Partner - Master III
Partner - Master III

If you use new dept field it will sum up salary for those to dept in one under MKT+MGT

ajaykumar1
Creator III
Creator III

Hi,

Please use the code as Shradda suggested.

Temp:

Load * inline

[

DEPT, SALARY

  MKT ,33500

  MGT, 45000

  LIB ,22000

  RND, 27500

  FIN, 42000

  ];

Load *,  If (wildmatch(DEPT,'MKT','MGT'),'MKT+MGT',DEPT) as New_Dept Resident Temp;

drop Table Temp;

Regards,

Ajay

MindaugasBacius
Partner - Specialist III
Partner - Specialist III

Use this script:

tmp:

LOAD salary

  ,If(Match(dep, 'MKT', 'MGT'), 'MKT & MGT', dep) as dep

INLINE [

  dep, salary

  MKT, 33500

  MGT, 45000

  LIB, 22000

  RND, 27500

  FIN, 42000

];

Table:

LOAD dep

  ,Sum(salary) as [Sum of salary]

Resident tmp

Group By dep

;

DROP Table tmp;

The result would be calculated in the script and the output would look like this:

Screenshot_1.jpg !