Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Presenting The Changed Salary - New & Old Value

Dears,

I hope you are doing well,

I am now developing a new report for HR Manager and one of the his request that he needs to see all salary changes happen for all employees in certain format.

The data structure like this:

   

Emp NameAmountStart Date
Jolly15002012-02-21
Jolly17002016-10-01
Sergo30002013-09-01
Sergo32502014-07-15
Sergo37002015-05-01
Sergo40002016-09-20
Sara9002015-07-29
Sara10002016-02-01
Sara12002016-03-01
Jon16002016-09-01

and I want to present it like this:

Emp NameOld AmountNew AmountLast Change
Jolly150017002016-10-01
Sergo300032502014-07-15
Sergo325037002015-05-01
Sergo370040002016-09-20
Sara90010002016-02-01
Sara100012002016-03-01
Jon160002016-09-01

Can anyone tell me how can I make this table.

Appreciate your support,

Thanks,

1 Solution

Accepted Solutions
MarcoWedel

Hi,

one solution could be:

QlikCommunity_Thread_238408_Pic1.JPG

tabTemp:

LOAD * FROM [https://community.qlik.com/thread/238408] (html, codepage is 1252, embedded labels, table is @1);

tabEmps:

LOAD [Emp Name],

    If([Emp Name]=Previous([Emp Name]), Previous(Amount), Amount) as [Old Amount],

    If([Emp Name]=Previous([Emp Name]),          Amount ,      0) as [New Amount],  

    [Start Date] as [Last Change],

    AutoNumber([Start Date],[Emp Name]) as ChangeNo

Resident tabTemp

Order By [Emp Name], [Start Date];

DROP Table tabTemp;

Right Join (tabEmps)

LOAD [Emp Name],

    ChangeNo

Resident tabEmps

Where [Emp Name]<>Previous([Emp Name]) or ChangeNo>1

Order By [Emp Name], ChangeNo desc;

DROP Field ChangeNo;

hope this helps

regards

Marco

View solution in original post

5 Replies
MarcoWedel

Hi,

one solution could be:

QlikCommunity_Thread_238408_Pic1.JPG

tabTemp:

LOAD * FROM [https://community.qlik.com/thread/238408] (html, codepage is 1252, embedded labels, table is @1);

tabEmps:

LOAD [Emp Name],

    If([Emp Name]=Previous([Emp Name]), Previous(Amount), Amount) as [Old Amount],

    If([Emp Name]=Previous([Emp Name]),          Amount ,      0) as [New Amount],  

    [Start Date] as [Last Change],

    AutoNumber([Start Date],[Emp Name]) as ChangeNo

Resident tabTemp

Order By [Emp Name], [Start Date];

DROP Table tabTemp;

Right Join (tabEmps)

LOAD [Emp Name],

    ChangeNo

Resident tabEmps

Where [Emp Name]<>Previous([Emp Name]) or ChangeNo>1

Order By [Emp Name], ChangeNo desc;

DROP Field ChangeNo;

hope this helps

regards

Marco

johnw
Champion III
Champion III

Could also do this:

Dimension 1  = Emp Name

Expression 1 = above(Amount)

Dimension 2  = Amount
Expression 2 = if(above(Amount),only([Start Date]))

Capture.PNG

But I usually don't like relying on chart inter-record functions because I don't usually like how they behave when I start making selections. I usually prefer modifying the data structures if I find myself doing chart inter-record functions.

Also, it doesn't give you the Jon line, but the Jon line makes no sense to me - Jon's salary did not go from 1600 to 0 on 2016-09-01. It went from 0 to 1600. But no other employees are showing a transition from 0 to their initial salary. So it just doesn't seem like Jon belongs in the chart.

See attached. Borrowed Marco's example.

Anonymous
Not applicable
Author

Hi Marco,

Thank you very much for your help, it is exactly what I want.

Thanks,

Ibrahim

Anonymous
Not applicable
Author

Hi John,

I fully agree with you and that is my intention to not show Jon's case because they don't have any salary changes and it doesn't make sense to present them in this report.

Thank you for your remarks.

Thanks,

Ibrahim

MarcoWedel

you're welcome

Glad it helped

regards

Marco