DAX Subtotals Profit and Loss statement


Well-known Member
I'm using the following method from Imke to produce a nicely formatted pivot table in Excel: https://www.thebiccountant.com/2016/07/21/easy-profit-loss-account-scheme-reports-power-bi-power-pivot-dax/

However, I am building on this to produce projected numbers.

For each reporting heading the user can choose to use a YTD average for the remaining periods or the latest month for each of the remaining periods.

The first measure is the same as Imke's post:
Amt_ :=
CALCULATE ( [Amt], AccountsAllocation )

The next measure uses the selected projection method to work out how much is to be applied to each future period:
BasisMonth :=
IF (
MIN ( ReportsAccountsLayout[Level] ) > 0,

IF (
[pBasis] = "YTD Average",
/ (
MAX ( CurrentPeriod[CurrentPeriod] )
- TRUNC ( MAX ( CurrentPeriod[CurrentPeriod] ) / 100 ) * 100
FactActuals[Period] = VALUES ( CurrentPeriod[CurrentPeriod] )

For October CurrentPeriod[CurrentPeriod] would be 202007. The financial year starts in April.

And finally, the basismonth is multiplied by the number of remaining periods:
ProjectedActual :=
* (
- (
MAX ( CurrentPeriod[CurrentPeriod] )
- TRUNC ( MAX ( CurrentPeriod[CurrentPeriod] ) / 100 ) * 100

At the moment subtotals are returning blanks (Bold in BasisMonth measure above) because I have no idea how to return the correct result.

Is anyone able to help?
Last edited:


Well-known Member
I went back to the drawing board and had a little think and I think I'm making it more complicated than I need to.

I'm currently trying to apply different formulas in the same measure and am trying to ask the subtotal to deal with this.

Instead what I think I should do is create three measures.

YTDMeasure - that calculates the YTD average or returns null if the Basis is montly
MonthlyMeasure - that calculates the current month or returns null if the basis is YTD
BasisMeasure - that sums the two above.

Which hopefully means the two different projection methods would propagate through to the subtotal..?!?!??11

Some videos you may like

This Week's Hot Topics

  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • find many based on a certain criteria
    good evening, I hope someone can help me? I have a workbook sheet 2 contains lots of data.... I would like to be able to find anything on sheet...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
  • Text Format
    I have a sheet for user to keyin the data. The format of the data can be 451 / 1903, 0012 / 9908 or 00287 / 0099. The number after the "/" is...
  • Macro to copy values across rows and transposing them and add the user id
    [FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]Hi,[/COLOR][/SIZE][/FONT] [FONT=Times New...