Forum Discussion
Iterate an operation between rows
Hi everyone.
I've got a table with the following columns:
- Item ID
- Date
- Warehouse ID
- Stock quantity
- Unitary cost of each item
- Stock value (for each item)
- Moved quantity (for sales)
I want to create another column that makes the subtraction between the quantity in stock (4th column) and the moved quantity (last column), for each item, warehouse and date. Do you know how to do it?
For example, for the second row I'd like to obtain the value 788,07 (817,31-29,24).
Many thanks.
Anonymous
I am not sure if I understood it correctly, you can add a column as follows:New Column = IF( [Quantita_movimentata] <> Blank() , [Quantita_in_Stock]-[Quantita_movimentata])
3 Replies
- Greg_DecklerCommunity Champion
Anonymous See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous - FowmySuper User
Anonymous
I am not sure if I understood it correctly, you can add a column as follows:New Column = IF( [Quantita_movimentata] <> Blank() , [Quantita_in_Stock]-[Quantita_movimentata])
- AnonymousNot applicable
Thank you.