Skip to content

HR - Payroll Analytics, and Employee Profile Changes (Job Grade, Department, and P&L) over time

>> Download the sample (Power BI)

This sample takes the following sample payroll dataset:…

…and shows the following HR metrics:

  1. All relevant Payroll Lines, for each Employee, in Matrix format
  2. Each person’s Payroll Rank, in a given Month, for each Payroll line. (If two employees are tied, e.g. because they are paid exactly the same, the tie is broken by ranking alphabetically on their User ID within the tied set.)
  3. Each person’s Payroll Line as a % of that Payroll line’s Total
  4. The Cumulative % Total of each Payroll line (according to each person’s Payroll Rank)
  5. The Total Salary by Month, along with ERs NI and Pension, shown as a % of Total Salary
  6. The Total Payroll Breakdown by Month (as a Bar Chart)
  7. The Total Payroll Breakdown by Department, by Month (as a 100% Stacked Bar Chart)
  8. Payroll changes, by person, from the Prior Month
  9. Job Grade, Department, or P&L changes, by person, from the Prior Month

Where relevant, YTD equivalent measures are also shown. Measures are also filterable by: User ID, P&L, Department, Job Grade, Nominal Ledger Line, and Month.

Possible extensions to this model could include:

  • Adding ‘Freelance or Permanent’ as an extra field to distinguish between amounts paid to different staff types.
  • Freelance records could be automatically linked and created from their Agency or own Limited Company Timesheet submissions.

[Amount [GBP]]] = CALCULATE ( SUM ( Payroll_Data[Amount] ) )
[Amount [GBP]] by Person] = CALCULATE (
SUM ( Payroll_Data[Amount] ),
ALLSELECTED(Payroll_Data[P&L]),
ALLSELECTED(Payroll_Data[Department]),
ALLSELECTED(Payroll_Data[Job Grade])
)
[Amount as [%]] of Total] = DIVIDE (
[Amount [GBP]]],
[Total Amount [GBP]] Selected Persons Only],
BLANK ()
)
Calculation Type =
IF (
HASONEVALUE ( 'Calculation Type'[Calc Type] ),
VALUES ( 'Calculation Type'[Calc Type] ),
BLANK ()
)
[Cumulative [%]]] = DIVIDE (
[Cumulative [GBP]] (without Ties)],
[Total Amount [GBP]] Selected Persons Only],
BLANK ()
)
[Cumulative [GBP]] (with Ties)] = VAR PersonRank = [Person Rank with Ties]
RETURN
CALCULATE (
[Amount [GBP]] by Person],
TOPN (
PersonRank,
GROUPBY (
SUMMARIZE (
ALLSELECTED ( Payroll_Data ),
[User ID],
[First Name],
[Last Name],
[P&L],
[Department],
[Job Grade]
),
[User ID],
[First Name],
[Last Name]
),
[Amount [GBP]] by Person]
)
)
[Cumulative [GBP]] (without Ties)] = VAR PersonRank = [Person Rank without Ties]
VAR PersonWithRankNotAbove =
FILTER (
GROUPBY (
SUMMARIZE (
ALLSELECTED ( Payroll_Data ),
[User ID],
[First Name],
[Last Name],
[P&L],
[Department],
[Job Grade]
),
[User ID],
[First Name],
[Last Name],
[P&L],
[Department],
[Job Grade]
),
[Person Rank without Ties] <= PersonRank
)
VAR TotalUptoCurrentPerson =
CALCULATE ( [Amount [GBP]] by Person], PersonWithRankNotAbove )
RETURN
TotalUptoCurrentPerson
[ERs NI [%]] of Salary Multi-Threaded] =
SWITCH (
TRUE (),
[Calculation Type] = "YTD", [YTD ERs NI as [%]] of YTD Salary],
[Calculation Type] = "Normal", [ERs NI [%]] of Salary],
BLANK ()
)
[ERs NI [GBP]] Multi-Threaded] =
SWITCH (
TRUE (),
[Calculation Type] = "YTD", [YTD ERs NI [GBP]]],
[Calculation Type] = "Normal", [ERs NI [GBP]]],
BLANK ()
)
[Pension [%]] of Salary Multi-Threaded] =
SWITCH (
TRUE (),
[Calculation Type] = "YTD", [YTD Pension [%]] of YTD Salary],
[Calculation Type] = "Normal", [Pension [%]] of Salary],
BLANK ()
)
[Pension [GBP]] Multi-Threaded] =
SWITCH (
TRUE (),
[Calculation Type] = "YTD", [YTD Pension [GBP]]],
[Calculation Type] = "Normal", [Pension [GBP]]],
BLANK ()
)
[Salary [GBP]] Multi-Threaded] =
SWITCH (
TRUE (),
[Calculation Type] = "YTD", [YTD Salary [GBP]]],
[Calculation Type] = "Normal", [Salary [GBP]]],
BLANK ()
)
[ERs NI [%]] of Salary] = DIVIDE([ERs NI [GBP]]], [Salary [GBP]]], BLANK())
[ERs NI [GBP]]] = CALCULATE(SUM(Payroll_Data[Amount]), Payroll_Data[NL Line]="ERs NI")
[Pension [%]] of Salary] = DIVIDE([Pension [GBP]]], [Salary [GBP]]], BLANK())
[Pension [GBP]]] = CALCULATE(SUM(Payroll_Data[Amount]), Payroll_Data[NL Line]="Pension")
[Salary [GBP]]] = CALCULATE(SUM(Payroll_Data[Amount]), Payroll_Data[NL Line]="Salary")
[YTD ERs NI [GBP]]] = TOTALYTD([ERs NI [GBP]]], Payroll_Data[Month])
[YTD ERs NI as [%]] of YTD Salary] = DIVIDE([YTD ERs NI [GBP]]], [YTD Salary [GBP]]], BLANK())
[YTD Pension [%]] of YTD Salary] = DIVIDE([YTD Pension [GBP]]], [YTD Salary [GBP]]], BLANK())
[YTD Pension [GBP]]] = TOTALYTD([Pension [GBP]]], Payroll_Data[Month])
[YTD Salary [GBP]]] = TOTALYTD([Salary [GBP]]], Payroll_Data[Month])
Person Rank with Ties = IF (
NOT ( HASONEVALUE ( Payroll_Data[User ID] ) ),
COUNTROWS ( GROUPBY ( ALLSELECTED ( Payroll_Data ), [User ID] ) ),
RANKX (
GROUPBY (
SUMMARIZE (
ALLSELECTED ( Payroll_Data ),
[User ID],
[First Name],
[Last Name],
[P&L],
[Department],
[Job Grade]
),
[User ID],
[First Name],
[Last Name]
),
[Amount [GBP]] by Person],
,
DESC,
SKIP
)
)
Person Rank without Ties = VAR CurrentPersonTotal = [Amount [GBP]] by Person]
VAR CurrentPerson =
MAX ( Payroll_Data[User ID] )
VAR AllRelevantPersons =
FILTER (
FILTER (
GROUPBY (
SUMMARIZE (
ALLSELECTED ( Payroll_Data ),
[User ID],
[First Name],
[Last Name],
[P&L],
[Department],
[Job Grade]
),
[User ID],
[First Name],
[Last Name]
),
[Amount [GBP]] by Person] >= CurrentPersonTotal
),
VAR TotalAmount = [Amount [GBP]] by Person]
VAR IteratedPerson = [User ID]
RETURN
( TotalAmount > CurrentPersonTotal ) + ( TotalAmount = CurrentPersonTotal ) * ( IteratedPerson < CurrentPerson )
)
VAR Result =
1 + COUNTROWS ( AllRelevantPersons )
VAR ShouldCalc =
ISFILTERED ( Payroll_Data[User ID] ) && HASONEVALUE ( Payroll_Data[User ID] )
RETURN
SWITCH (
TRUE (),
NOT ( HASONEVALUE ( Payroll_Data[User ID] ) ), COUNTROWS ( GROUPBY ( ALLSELECTED ( Payroll_Data ), [User ID] ) ),
ShouldCalc, Result,
BLANK ()
)
[Total Amount [GBP]] Selected Persons Only] = CALCULATE (
SUM ( Payroll_Data[Amount] ),
ALLSELECTED ( Payroll_Data[User ID] ),
ALLSELECTED ( Payroll_Data[First Name] ),
ALLSELECTED ( Payroll_Data[Last Name] ),
ALL ( Payroll_Data[P&L] ),
ALL ( Payroll_Data[Department] ),
ALL ( Payroll_Data[Job Grade] )
)
[Amount M-1 [GBP]] by Person] =
CALCULATE ( [Amount [GBP]] by Person], PREVIOUSMONTH ( Payroll_Data[Month] ) )
Department Change = IF (
AND ( MONTH ( AVERAGE ( Payroll_Data[Month] ) ) <> 1, HASONEFILTER ( Payroll_Data[Month] ) ),
SWITCH (
TRUE (),
[Last Department] = [Last Department PM], "No Change",
"Change"
),
BLANK ()
)
Department Change Color =
VAR DepartmentGrade = [Department Change]
RETURN
SWITCH (
TRUE (),
DepartmentGrade = "Change", "#FFF7A9",
DepartmentGrade = "No Change", "#EBEBEB",
"#FFFFFF"
)
Job Grade Change = IF (
AND ( MONTH ( AVERAGE ( Payroll_Data[Month] ) ) <> 1, HASONEFILTER ( Payroll_Data[Month] ) ),
SWITCH (
TRUE (),
[Last Job Grade] = [Last Job Grade PM], "No Change",
"Change"
),
BLANK ()
)
Job Grade Change Color =
VAR JobGrade = [Job Grade Change]
RETURN
SWITCH (
TRUE (),
JobGrade = "Change", "#FFF7A9",
JobGrade = "No Change", "#EBEBEB",
"#FFFFFF"
)
Last Department = CALCULATE (
MAX ( Payroll_Data[Department] ),
FILTER (
GROUPBY ( Payroll_Data, [P&L], [Job Grade], [User ID], [Month], [NL Line], [Start Date] ),
Payroll_Data[Start Date] = MAX ( Payroll_Data[Start Date] )
),
ALL(Payroll_Data[P&L]),
ALL(Payroll_Data[Job Grade])
)
Last Department PM = CALCULATE (
[Last Department],
PREVIOUSMONTH ( Payroll_Data[Month] ),
ALL ( Payroll_Data[P&L] ),
ALL ( Payroll_Data[Job Grade] )
)
Last Job Grade = CALCULATE (
MAX(Payroll_Data[Job Grade]),
FILTER (
GROUPBY ( Payroll_Data, [P&L], [Department], [User ID], [Month], [NL Line], [Start Date] ),
Payroll_Data[Start Date] = MAX(Payroll_Data[Start Date])
),
ALL(Payroll_Data[P&L]),
ALL(Payroll_Data[Department])
)
Last Job Grade PM = CALCULATE (
[Last Job Grade],
PREVIOUSMONTH ( Payroll_Data[Month] ),
ALL ( Payroll_Data[P&L] ),
ALL ( Payroll_Data[Department] )
)
Last P&L = CALCULATE (
MAX ( Payroll_Data[P&L] ),
FILTER (
GROUPBY ( Payroll_Data, [Department], [Job Grade], [User ID], [Month], [NL Line], [Start Date] ),
Payroll_Data[Start Date] = MAX ( Payroll_Data[Start Date] )
),
ALL(Payroll_Data[Department]),
ALL(Payroll_Data[Job Grade])
)
Last P&L PM = CALCULATE (
[Last P&L],
PREVIOUSMONTH ( Payroll_Data[Month] ),
ALL ( Payroll_Data[Department] ),
ALL ( Payroll_Data[Job Grade] )
)
P&L Change = IF (
AND ( MONTH ( AVERAGE ( Payroll_Data[Month] ) ) <> 1, HASONEFILTER ( Payroll_Data[Month] ) ),
SWITCH (
TRUE (),
[Last P&L] = [Last P&L PM], "No Change",
"Change"
),
BLANK ()
)
P&L Change Color =
VAR PnL = [P&L Change]
RETURN
SWITCH (
TRUE (),
PnL = "Change", "#FFF7A9",
PnL = "No Change", "#EBEBEB",
"#FFFFFF"
)
Payroll Change = IF (
AND ( MONTH ( AVERAGE ( Payroll_Data[Month] ) ) <> 1, HASONEFILTER ( Payroll_Data[Month] ) ),
SWITCH (
TRUE (),
[Payroll Variance [GBP]]] > 5, "Up",
[Payroll Variance [GBP]]] < 5, "Down",
"No Change +/- £5"
),
BLANK ()
)
[Payroll Variance [GBP]]] = IF (
AND ( MONTH ( AVERAGE ( Payroll_Data[Month] ) ) <> 1, HASONEFILTER( Payroll_Data[Month]) ),
[Amount [GBP]] by Person] - [Amount M-1 [GBP]] by Person],
BLANK ()
)