Molotch
Molotch

Reputation: 475

Averaging a measure/create a table from measure DAX

I have a measure calculating the running balance of invoices, see this question DAX model invoice running balance. Now I would like to be able to average the running balance filtered by the query context.

Ie Id like somehow to return a table using DateDim with a calculated invoice balance per day and average over that table using the selected period in the query context. I've tried some solutions but really haven't found a smart way to do it.

Upvotes: 0

Views: 1711

Answers (1)

greggyb
greggyb

Reputation: 3798

AveragedRunningBalance:=
AVERAGEX(
    DimDate
    ,[InvoiceBalanceToDate]
)

This will step row-by-row through the dates in context (logical and of the rowfilter, columnfilter, slicer, and filter selections in the pivot), calculating [InvoiceBalanceToDate] for each row in that table, and accumulating those individual results in an average (sum of individuals divided by number of dates in DimDate in context).

Upvotes: 1

Related Questions