Forum Discussion
Lund
3 years agoFrequent Visitor
Calculate cumulative stock value
Hi
I have this messaure where i do a cumulativestock quantity. Works like a charm!
_cuml Stock QTY =
CALCULATE (
SUM ( 'Item ledger Entry'[Quantity] ),
FILTER ( ALL ( 'Item ledger Entry' ), 'Item ledger Entry'[Posting Date] <= MAX ( 'Item ledger Entry'[Posting Date] ) )
)
But i also need a messaure the stock value.
I have a related table Products where i got the [Internal Cost].
I have a related table Products where i got the [Internal Cost].
Then i need somehow to multiply my sum of quantity with [Internal Cost]
I have tried somthing like this (inspired from https://community.powerbi.com/t5/DAX-Commands-and-Tips/Calculating-cumulative-stock-value/m-p/2172357#M50456 )
_Cuml Stock Value =
CALCULATE (
SUMX ( Products, Products[Internal Cost] * RELATED('Item ledger Entry'[Quantity]) ),
FILTER ( ALL ( 'Item ledger Entry'), 'Item ledger Entry'[Posting Date] <= MAX ('Item ledger Entry'[Posting Date]) )
)
But RELATED() dosent work. Get this error: The parameter is not of the correct type
Can you help me with the solution?
Lund , related can be used for table on one side
_Cuml Stock Value =
CALCULATE (
SUMX ('Item ledger Entry' , realted(Products[Internal Cost]) * ('Item ledger Entry'[Quantity]) ),
FILTER ( ALL ( 'Item ledger Entry'), 'Item ledger Entry'[Posting Date] <= MAX ('Item ledger Entry'[Posting Date]) )
)
2 Replies
- amitchandak
Super User
Lund , related can be used for table on one side
_Cuml Stock Value =
CALCULATE (
SUMX ('Item ledger Entry' , realted(Products[Internal Cost]) * ('Item ledger Entry'[Quantity]) ),
FILTER ( ALL ( 'Item ledger Entry'), 'Item ledger Entry'[Posting Date] <= MAX ('Item ledger Entry'[Posting Date]) )
)
- LundFrequent Visitor
Oh, okay. Thanks alot!