Forum Discussion
A seemingly complex task...
A measure will need some way of calculating its "previous" row, as there is no built in concept of row numbers in power bi. Sometimes people use dates for this, often they use an index column.
An index column would imply that all your pallets were sorted in the correct order.
Then your measure can do a sum() of all the rows with the index > the row it is executing on
which sort of implies that you have filtered the records to contain pallets with that part
I created a "Pallet Ranking" by going into query editor, and sorting first by SKU, then LOT, then FIFO date, and adding an Index column.
Seems to work. So how would I create the running total measure? I tried the following but it did not work:
- kentyler6 years agoSolution SageI think you want to store the current value before you do calculateCumulative Qty =var cur_index = max('inventory'[Pallet rank])CALCULATE (SUM( 'Inventory'[ONHAND_QTY] ),FILTER (ALL ( 'Inventory'[Pallet Rank] ),'Inventory'[Pallet Rank] <= cur_index )))
- CoreyP6 years agoSolution Sage
That doesn't seem to be working. Just returns 1 for every value. Do we have to take item_no into context somehow?
- kentyler6 years agoSolution Sage
If you just return the current index, does it show the correct number ?
- CoreyP6 years agoSolution Sage
This is what it returns:
Using this measure:
Cumulative Qty =VAR cur_index = MAX('Inventory'[Pallet Rank])RETURNCALCULATE (SUM( 'Inventory'[ONHAND_QTY] ),FILTER (ALL('Inventory'[Pallet Rank]),'AIRMInventory'[Pallet Rank] <= cur_index ))