Forum Discussion

delmayhan's avatar
delmayhan
Frequent Visitor
2 years ago

Rolling Stock DAX Measure

Hi Guys,

I want to create a rolling stock measure in Powerbi from a base value that is a field. So till now what i created is this measure :

Planned Stock =
CALCULATE (
( [Planned Delivery Quantity (Base Unit)] -[Required Quantity (Base Unit)] ) ,
FILTER (
ALL ( 'Date'[Date] ),
'Date'[Date] <= MAX ( ( 'Date'[Date] ) )
)
) Planned Stock this works fine.

 

Only what i want to do is that it take a starting stock from this field sum('inventory[QuantityUnrestricted] ') then it does the same as the measure in the planned stock. I tried but it didnt succeed. This is the measure:

RollingStockWithStartValue =
VAR __startValue = SUM('Inventory'[QuantityUnrestricted])
VAR __currentRow = MIN('Date'[Date])

RETURN
    IF(
        ISBLANK(__currentRow),
        BLANK(),
        __startValue +
        CALCULATE(
            [Planned Delivery Quantity (Base Unit)] - [Required Quantity (Base Unit)],
            FILTER(
                ALL('Date'),
                'Date'[Date] <= __currentRow
            )
        )
    )
and this is the output

i wanted it to be on the 10/10/2023  1480-256,16 and from that point will that be the value till there is other requirement or delivery

 

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi delmayhan ,

     

    I think you can try code as below to create a new measure based on original [RollingStockWithStartValue] measure.

    NEWRollingStockWithStartValue =
    SUMX (
        FILTER ( ALL ( Date ), 'Date'[Date] <= MAX ( 'Date'[Date] ) ),
        [RollingStockWithStartValue]
    )

    If this reply still couldn't help you solve your issue, please share a sample file with us.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.