Forum Discussion

Ronald123's avatar
Ronald123
Resolver III
8 years ago
Solved

Cumulative total supply

 

Hello,

 

I need a dax formule for the cumulative total supply. This is a total by the colum "Subgroep" filter by months, some items are sold. 

Can anyone help my?

 

 

 

Tabelname:Stock      Tabelname:Calender   
             
Itemcode (unique)SubgroepAmountDate purchaseDate sale   MonthsMeasure: Cumulative total stocks Filter 
12Drinks12-1-2017    1  Subgroup:Drinks
13Drinks13-1-2017    2  Year:2017
14Drinks12-2-20174-4-2017   3    
15Drinks13-2-2017    4    
16Drinks14-3-2017    5    
17Drinks15-4-20176-7-2017   6    
21Fruit11-1-2017    7    
22Fruit12-3-2017    8    
23Fruit12-4-2017    9    
24Fruit12-5-20178-2-2017   10    
25Fruit12-6-2017    11    
26Fruit12-7-20172-8-2017   12    
27Fruit12-8-2018         
             
  • Hi Ronald123,

    Please change the formula as the following one shown.

    sale=IF(ISBLANK(Table[Date Sale]),0,-1)


    Best Regards,
    Angelia

     

8 Replies

  • jmalone's avatar
    jmalone
    Resolver III

    You need supply by Subgroep? In other words, you need to see the cumulative supply of Drinks, separate from the supply of Fruit, correct?

     

    You might try this:

    Cumulative Supply = 
    CALCULATE (
        SUM ( 'Stock'[Amount] ),
        FILTER (
            ALLEXCEPT ( 'Stock', 'Stock'[Subgroep] ),
           'Stock'[Date purchase] <= MAX( 'Stock'[Date purchase] )
        ) ,
            'Stock'[Date Sale] = BLANK ()
    )
    - 
    CALCULATE (
        SUM ( 'Stock'[Amount] ),
        FILTER (
            ALLEXCEPT ( 'Stock', 'Stock'[Subgroep] ),
           'Stock'[Date purchase] <= MAX( 'Stock'[Date purchase] )
        ) ,
            'Stock'[Date Sale] <> BLANK ()
    )

     

     

    • Ronald123's avatar
      Ronald123
      Resolver III

       

      Thank's jmalone for the measure. 

      The total result of the subgroep fruit's must be 5, the measure let me see a total of 3 on 31-12-2017.

      This happend when a item is sold. 

       

      Did anyone have an solution?

       

       

       

       

       

       

       

       

      • v-huizhn-msft's avatar
        v-huizhn-msft
        Microsoft Employee

        Hi Ronald123,

        The total result of the subgroep fruit's must be 5, why should be 5, could you please describe the calculation rules?

        Best Regards,
        Angelia