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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
inam6713
Contributor
Contributor

Add new record in column

Hello Qlik Community,

I have a QlikView pivot table with a column named Seperation_Status that contains various records. These records are generated within the script. I need to add Closing Headcount based on the following formula:

Closing Headcount = Opening Headcount + New Joiners – Total Exits + Transfer In/Outinam6713_0-1739184189452.png

Could you please help me implement this at the script level or provide a solution at the frontend level?

Thank you! 😊

expected output:-

Seperation_Status Mapping Name for Tool CT
New Joinee   3
Voluntary   8
Involuntary   -
Retirement   -
Total number of Exits   8
Opening Headcount   337
Transfer In/Out   2
closing_headcount   334
Labels (2)
2 Replies
JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @inam6713 
Can you provide a sample data set? The "trick" here would be to build a Multiplier to change the actual value. 

Like a Exit would be -1 and joiner would be 1. This way you can just do a sum to get the closing headcount. I also assume that Transfer In/Out would already be a negative / positive based on the "end result" - Hence the reason requesting a sample dataset. 

Regards 

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn

Chanty4u
MVP
MVP

Try this 

FinalTable:

LOAD *,

    If(Separation_Status = 'Opening Headcount', CT, 0) AS Opening_Headcount,

    If(Separation_Status = 'New Joinee', CT, 0) AS New_Joiners,

    If(Separation_Status = 'Voluntary' OR Separation_Status = 'Involuntary' OR Separation_Status = 'Retirement', CT, 0) AS Total_Exits,

    If(Separation_Status = 'Transfer In/Out', CT, 0) AS Transfers

RESIDENT SeparationData;

 

DROP TABLE SeparationData;

 

ClosingHeadcount:

LOAD 

    'closing_headcount' AS Separation_Status,

    (Sum(Opening_Headcount) + Sum(New_Joiners) - Sum(Total_Exits) + Sum(Transfers)) AS CT

RESIDENT FinalTable;

Concatenate(FinalTable)

LOAD * RESIDENT ClosingHeadcount;

 

DROP TABLE ClosingHeadcount;