Forum Discussion
Alternative for AverageX
(Cumulative) Closing Balance =
CALCULATE([Closing Balance]|
filter ( ALL('Date'[Date])|'Date'[Date] <= max ('Date'[Date]))
)
(Cumulative) Opening Balance =
CALCULATE([Closing Balance]|
filter ( ALL('Date'[Date])|'Date'[Date] <= (max ('Date'[Date])-1))
)
where Closing Balance =
Var Amount = Sum(Accounting[Home_Currency_Amount]))
Var Debit_Amt = CALCULATE([Amount],Accounting[Debit_Credit]="DR")
Var Credit_Amt = CALCULATE([Amount],Accounting[Debit_Credit]="CR")
Return
Debit_Amt - Credit_Amt
hmm,
so the way the opening and closing balance is calculated, is to sum up all prior transactions. So if a report user is trying to see the average daily balance for a month, using averagex, this process is repeated for each day. And if the report is drilled down to GL Code Level 1, the number of calculations is multiplied with number of GL Code Level 1 visible in the visual. With a table with small number of rows it will work. With a table with a high number of rows, it will be slow and you might run out of memory.
I think you will have to create a table containing the opening and closing balance for each account for each day in order to imrpove the query speed.