Finance - P&L Tracking – Customised & Nested Pivot Tables

Finance - P&L Tracking – Customised & Nested Pivot Tables

In this sample, we track Actuals against Budgeted amounts, for each P&L line, showing variances too, in a Pivot Table. Simple Pivot Tables are relatively easy to create and use, but for this file we add the condition of also needing to show the additional lines such as ‘Gross Profit’, ‘Operating Income’, which do not appear in the source GL data - in effect we need to create a highly-customised customised Pivot Table.

Data Inputs

For this sample, we take the following data inputs:

Dimensions

The dimension tables will be determined by the current structure of the business

Accounts Structure

This is where we define the layout and mappings of the P&L lines to different Headings and Sub Accounts

General Ledger

The GL here contains both the Actuals and Budgeted data for each month, so both datasets are already available to us in a nice, easy to work with format, in the same table.

P&L Tracking Measures

The following specific measures are shown:

  1. Actuals
  2. Budget
  3. Variance $
  4. Variance %

Dashboard - Snippet

Unlike most of our other samples, the final output here in presented in Excel itself, rather than through a Power BI dashboard – which is great for visuals, but not as strong with tables. When it comes to just pivot tables, it is a matter of preference.

The final file can also be downloaded here, if you want to review the formulae in detail: Download Sample cloud_download

Click to view large-sized image

Data Model - Snippet

The final data model used is shown here:

Click to view large-sized image

Measures

SUM GL Amt

DAX
SUM GL Amt :=
SUM ( 'General_Ledger'[Amount] )

GL Amt (Correct Signs)

DAX
GL Amt (Correct Signs) :=
SUMX ( Accounts, [SUM GL Amt] * Accounts[Report Sign] )

Actual Amt

DAX
Actual Amt :=
CALCULATE ( [GL Amt (Correct Signs)], Scenarios[ScenarioName] = "Actual" )

Rev Act

DAX
Rev Act :=
CALCULATE ( [Actual Amt], Headers[Header] = "Revenue" )

CoS Act

DAX
CoS Act :=
CALCULATE ( [Actual Amt], Headers[Header] = "Cost of Sales" )

GP Act

DAX
GP Act :=
[Rev Act] + [CoS Act]

OpEx Act

DAX
OpEx Act :=
CALCULATE ( [Actual Amt], Headers[Header] = "Operating Expenses" )

OI Act

DAX
OI Act :=
[GP Act] + [OpEx Act]

OI&E Act

DAX
OI&E Act :=
CALCULATE ( [Actual Amt], Headers[Header] = "Other Income & Expense" )

D&A Act

DAX
D&A Act :=
CALCULATE ( [Actual Amt], Headers[Header] = "Depreciation & Amortization" )

II&E Act

DAX
II&E Act :=
CALCULATE ( [Actual Amt], Headers[Header] = "Interest Income/Expense" )

Taxes Act

DAX
Taxes Act :=
CALCULATE ( [Actual Amt], Headers[Header] = "Taxes" )

NI Act

DAX
NI Act :=
[OI Act] + [OI&E Act] + [D&A Act] + [II&E Act] + [Taxes Act]

IS Subtotal Act

DAX
IS Subtotal Act :=
IF (
    COUNTROWS ( VALUES ( Headers[Header] ) ) = 1,
    SWITCH (
        VALUES ( Headers[Header ID] ),
        1, [Rev Act],
        2, [CoS Act],
        3, [GP Act],
        4, [OpEx Act],
        5, [OI Act],
        6, [OI&E Act],
        7, [D&A Act],
        8, [II&E Act],
        9, [Taxes Act],
        10, [NI Act],
        BLANK ()
    ),
    BLANK ()
)

Actual Total

DAX
Actual Total :=
IF (
    MAX ( Headers[Summary] ) = 1
        && (
            MAX ( Headers[Show Detail] ) = 1
                || COUNTROWS ( VALUES ( Subheader[Subheader] ) ) > 1
        ),
    [IS Subtotal Act],
    [Actual Amt]
)

Budget Amt

DAX
Budget Amt :=
CALCULATE ( [GL Amt (Correct Signs)], Scenarios[ScenarioName] = "Budget" )

Rev Bud

DAX
Rev Bud :=
CALCULATE ( [Budget Amt], Headers[Header] = "Revenue" )

CoS Bud

DAX
CoS Bud :=
CALCULATE ( [Budget Amt], Headers[Header] = "Cost of Sales" )

GP Bud

DAX
GP Bud :=
[Rev Bud] + [CoS Bud]

OpEx Bud

DAX
OpEx Bud :=
CALCULATE ( [Budget Amt], Headers[Header] = "Operating Expenses" )

OI Bud

DAX
OI Bud :=
[GP Bud] + [OpEx Bud]

OI&E Bud

DAX
OI&E Bud :=
CALCULATE ( [Budget Amt], Headers[Header] = "Other Income & Expense" )

D&A Bud

DAX
D&A Bud :=
CALCULATE ( [Budget Amt], Headers[Header] = "Depreciation & Amortization" )

II&E Bud

DAX
II&E Bud :=
CALCULATE ( [Budget Amt], Headers[Header] = "Interest Income/Expense" )

Taxes Bud

DAX
Taxes Bud :=
CALCULATE ( [Budget Amt], Headers[Header] = "Taxes" )

NI Bud

DAX
NI Bud :=
[OI Bud] + [OI&E Bud] + [D&A Bud] + [II&E Bud] + [Taxes Bud]

IS Subtotal Bud

DAX
IS Subtotal Bud :=
IF (
    COUNTROWS ( VALUES ( Headers[Header] ) ) = 1,
    SWITCH (
        VALUES ( Headers[Header ID] ),
        1, [Rev Bud],
        2, [CoS Bud],
        3, [GP Bud],
        4, [OpEx Bud],
        5, [OI Bud],
        6, [OI&E Bud],
        7, [D&A Bud],
        8, [II&E Bud],
        9, [Taxes Bud],
        10, [NI Bud],
        BLANK ()
    ),
    BLANK ()
)

Budget Total

DAX
Budget Total :=
IF (
    MAX ( Headers[Summary] ) = 1
        && (
            MAX ( Headers[Show Detail] ) = 1
                || COUNTROWS ( VALUES ( Subheader[Subheader] ) ) > 1
        ),
    [IS Subtotal Bud],
    [Budget Amt]
)

Variance $

DAX
Variance $ := [Actual Total] - [Budget Total],

Variance %

DAX
Variance % := DIVIDE ( [Variance $], [Budget Total] )