# Calculating Wage type average for ‘n’ number of previous periods in the Payroll

Good Day!!!

Few days back I got a chance to work on a scenario which is quite interesting. I hope this blog will be helpful for others.

*Requirement:*

I have to calculate the 12 periods average of employee pensionable pay when the employee leaves on maternity.

Most of our requirements will be in such a way that reading the Wage type from LRT (i.e,. last RT table) but for calculating 12 periods ? ðŸ˜¯

Here the difficult part is to get the 12 periods wage type value and finding the average for it.

In this blog, I will try to explain about calculating the ‘n’ previous period results.

I have designed my PCR for one time calculation, i.e,. /WAM is generated only for the first period when the employee leaves on maternity and for other periods it will not be calculated. The average of previous periods is calculated only for a period, you can alter it based on your requirement.

I have also found a knowledgeable document with similar requirement but in different approach from Trong Minh (Woody) Nguyen – Payroll processing – Calculate average 6 month Basic Salary which also helps.

**Key factor:**

IMPRE and PLOOP – Operations.

Syntax:

Syntax:

**Solution based on PCR:**

* Note:* Here

**‘X’**denotes the number of payroll periods you require for calculating the average ,

**‘YYYY’**denotes the placeholder wagetype for the average calculated and

**‘ZZZZ**‘ denotes the corresponding wage type which is subjected to get previous values in payroll. In Step 2, **** -> you can restrict it to specific wage type inorder to avoid the PCR running for all wage types.

With Regards,

Giriesh M