Forum Discussion
Running total from multiple sources , starting from ground value?
- 4 years ago
Hi, vpsoini
ItemNo 2 should have a remaining amount of 19 on January 12.Try to create a measure like this:
Measure = SUM(Items[Inventory])+ CALCULATE( SUM(ItemLedger[Qty]), FILTER(ALL(ItemLedger),'ItemLedger'[ItemNo]=MAX('Items'[ItemNo])&&'ItemLedger'[Date]<=MAX('ItemLedger'[Date])))Result:
Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon ZhengIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
vpsoini , This should use a calendar table
like
CALCULATE(SUM('Purchases'[Quantity]),FILTER(ALLSELECTED('Calendar'),'Calendar'[Date] <= MAX('Calendar'[Date])))
CALCULATE(SUM('Sales'[Quantity]),FILTER(ALLSELECTED('Calendar'),'Calendar'[Date] <= MAX('Calendar'[Date])))
and month, date, qtr, year table should always come from Calendar
Also, you might need all not allselected
CALCULATE(SUM('Purchases'[Quantity]),FILTER(all('Calendar'),'Calendar'[Date] <= MAX('Calendar'[Date])))
CALCULATE(SUM('Sales'[Quantity]),FILTER(all('Calendar'),'Calendar'[Date] <= MAX('Calendar'[Date])))
or like
Inventory =
Var _max = maxx(allselected('Calendar') , 'Calendar'[date])
return
CALCULATE(SUM('Purchases'[Quantity]),FILTER(all('Calendar'),'Calendar'[Date] <= MAX('Calendar'[Date]) && 'Calendar'[Date] <=_max )) -
CALCULATE(SUM('Sales'[Quantity]),FILTER(all('Calendar'),'Calendar'[Date] <= MAX('Calendar'[Date]) && 'Calendar'[Date] <=_max ))