Hi,
I have a fairly large transaction table (over 27 million lines and growing) with inventory and their related cost transactions. To get a inventory (or cost ) on hand balance I do the standard formula
Balance Qty = CALCULATE(SUM('Item Value New'[Item Ledger Entry Quantity]),FILTER(ALL(Dates),Dates[Date]<=MAX(Dates[Date])))
Which works great. However, Now what I want to do is get an average of the inventory balances on hand over a date range. That way for items that are produced less often we still get a good idea of the carrying quantity and value of inventory.
To do so, I first tried creating a new table with summarize columns that would have the balance on hand for each date, and then taking an average of that balance
Inv Summary Col = SUMMARIZECOLUMNS('Item Value New'[Item Ledger Entry Quantity], 'Item Value New'[Posting Date],
"Bal Qty", CALCULATE(SUM('Item Value New'[Item Ledger Entry Quantity]), FILTER(ALL('Item Value New'[Posting Date]), 'Item Value New'[Posting Date]<=MAX('Item Value New'[Posting Date] ) ) ),
"Bal Cost", CALCULATE(SUM('Item Value New'[Cost Amount (Actual)]) , FILTER(ALL('Item Value New'[Posting Date]) , 'Item Value New'[Posting Date] <= MAX('Item Value New'[Posting Date] ) ) )
)
Then I do an average with something like
Average(Bal Qty)
However, while that worked fine in Power BI desktop, every time I tried to refresh from the Power BI service I got a memory allocation error after the refresh timed out at around two hours.
So now I tried an alternate method. Basically just two measures
Balance Qty = CALCULATE(SUM('Item Value New'[Item Ledger Entry Quantity]),FILTER(ALL(Dates),Dates[Date]<=MAX(Dates[Date])))
followed by
Avg Bal Qty = AVERAGEX(VALUES(Dates[Date]),[Balance Qty])
Which seems like it’s doing the job, but when I update the matrix (say expand the product hierarchy, or switch to a different product category), things are going REALLY slow.
So is there a better way to approach this?
Thanks,