Forum Discussion

Lund's avatar
Lund
Frequent Visitor
3 years ago
Solved

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].
Then i need somehow to multiply my sum of quantity with [Internal Cost]
 
 
_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

  • 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]) )

    )

    • Lund's avatar
      Lund
      Frequent Visitor

      Oh, okay. Thanks alot!