Forum Discussion

timo980111's avatar
timo980111
Frequent Visitor
3 years ago

Stock level Calculation

Hi guys,

I'm new at DAX, but I can't find any solution that fits for my problem. 

Maybe one of you can help me. 

I would like to calculate my future stock level based on the following table.

The last available stock is index 29. After that I would like to calculate the stock.

My idea is to calculate the stock level with the following formular: Stock[x]= (Stock[29] + SUM(DELTA[29:X]). 

Could someone please help me with the DAX?

 

3 Replies

  • Hi timo980111 , Please use the below,

     

    Calculated column  = 
    var index29stock = CALCULATE( MAX('table1'[BESTAND]), FILTER( 'table1'[Index]=29))

    var futurestock = index29stock + 'table1'[delta]

    RETURN

    futurestock

     

    Regards,

    Nikhil Chenna

     

    Appreciate with a Kudos!! (Click the Thumbs Up Button)
    Did I answer your question? Mark my post as a solution!

    • timo980111's avatar
      timo980111
      Frequent Visitor

      Unfortunately it's not working - Just to clarify I need the following formular as DAX:

      Example for index31 -> stock31 = index29stock + Delta29 + Delta30 + Delta31.

      Example for index32 -> stock32 = index29stock + Delta29 + Delta30 + Delta31.

      • v-easonf-msft's avatar
        v-easonf-msft
        Community Support

        Hi, timo980111 

        Please try formula like:

        Measure1 =
        VAR stock29 =
            CALCULATE ( [M_stock], FILTER ( Table1, Table1[Index] = 29 ) )
        RETURN
            SUMX (
                FILTER (
                    ALL ( Table1 ),
                    Table1[Index] <= MAX ( Table1[Index] )
                        && Table1[Index] >= 29
                ),
                [M_DELTA]
            ) + stock29
        

        Best Regards,
        Community Support Team _ Eason