Forum Discussion
Calculating Projected Stock
- 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.
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.
Hi MFelix , I did a mistake when translating your formula to my original data structure. I also changed the data structure slightly. The forecast from last Sunday is now DataType "Stock Weekly". And now it works.
Many thanks again for your help!
Cheers
Malte