Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Calculating Projected Stock

Hi all,   I want to be able to extrapolate my inventory into the future by adding incoming goods (Planned and Scheduled) and subtracting expected sales (Forecast Weekly). The most recent stock I ha...
  • MFelix's avatar
    5 years ago

    hI Anonymous 

     

    First of all your Datedimension need to be continuous other wise your calculation will no work properly, so you need to unfiltered the dates you have taken out.

     

    I'm assuming that the values that you have for Stock will be in a fixed date in this case you have october 18th then I made the following calculaiton:

    m.Stock.PL = 
    VAR Stock_Date =
        MAXX (
            FILTER (
                ALL ( FactTable[Date ID Weekly]; FactTable[DataType] );
                FactTable[DataType] = "Stock"
            );
            FactTable[Date ID Weekly]
        )
    RETURN
        IF (
            [m.ForecastWeekly.PL] = BLANK ()
                && [m.Scheduled.PL] = BLANK () 
                && [m.Planned.PL] = BLANK ();
            BLANK ();
            CALCULATE (
                SUM ( FactTable[Volume in PL] );
                FactTable[DataType] = "Stock";
                FILTER (
                    ALL ( DateDimension[Date ID Weekly] );
                    DateDimension[Date ID Weekly] <= SELECTEDVALUE ( DateDimension[Date ID Weekly] )
                )
            )
                - CALCULATE (
                    [m.ForecastWeekly.PL] - [m.Scheduled.PL]  - [m.Planned.PL];
                    FILTER (
                        ALL ( DateDimension[Date ID Weekly] );
                        DateDimension[Date ID Weekly] <= SELECTEDVALUE ( DateDimension[Date ID Weekly] )
                            && DateDimension[Date ID Weekly] > Stock_Date
                    )
                )
        )

     

    Since the planned value is 0 on this case I don't know if you want to sum for the total or subtract you just need to adjust the measure to make the correct calculation.