Hi everyone,First post in here about this so here goes. We use MS Dynamics Nav as our ERP and I'm having difficulty stitching together forecasts and actuals to give a full year position.Item_ID = Item_1 is sold in units of 10. For each Item_1 outer we sell, this contains 10 inners. We store both elements of data per transaction lineItem_ID is a surrogate key linked to the item hierarchy.Customer_ID = Customer_1 who is one of our customers to whom we sell Item_1.We have iterations of forecast which we revise monthlyForecast 1 is FC1Forecast 2 is FC2etc..Each forecast is an estimate at that point in time, and always looks forward.i.e. FC1 is the forecast done for the period of June through OctoberFC2 is the forecast done at the end of June, looking at July through Octoberetc...Forecasts are stored per item, per customer, per date in a table called Item Budget entry.If we planned to sell customer 1, Item 11 outer in Jun2 outers in Jul3 outers in Aug4 outers in Sep5 outers in Octthe data might would look like:FC1| Item_1| Customer_1| '2014-06-01'|1|10FC1| Item_1| Customer_1| '2014-07-01'|2|20FC1| Item_1| Customer_1| '2014-08-01'|3|30FC1| Item_1| Customer_1| '2014-09-01'|4|40FC1| Item_1| Customer_1| '2014-10-01'|5|50Then if we revise the forecast in the iteration FC2, 3 outers in Jul4 outers in Aug5 outers in Sep6 outers in Octthese get appended to the table so it now looks like:FC1| Item_1| Customer_1| '2014-06-01'|1|10FC1| Item_1| Customer_1| '2014-07-01'|2|20FC1| Item_1| Customer_1| '2014-08-01'|3|30FC1| Item_1| Customer_1| '2014-09-01'|4|40FC1| Item_1| Customer_1| '2014-10-01'|5|50FC2| Item_1| Customer_1| '2014-07-01'|3|30FC2| Item_1| Customer_1| '2014-08-01'|4|40FC2| Item_1| Customer_1| '2014-09-01'|5|50FC2| Item_1| Customer_1| '2014-10-01'|6|60Sales are derived using a query which takes the "Union All" of our sales Invoice lines and Sales Credit memo lines tables. In the cube we are able to see this data which in SQL looks like:[b]ITEM_ID|CUSTOMER_ID|Date|Volume in measure 1|Volume in measure 2[/b]Item_1|Customer_1|'2014-01-01'|1|10Item_1|Customer_1|'2014-02-01'|2|20Item_1|Customer_1|'2014-03-01'|-1|-10Item_1|Customer_1|'2014-04-01'|4|40Item_1|Customer_1|'2014-05-01'|4|40Item_1|Customer_1|'2014-06-01'|3|30Item_1|Customer_1|'2014-07-01'|6|60We have relationships via surrogate keys for the Items and customers. Dates are linked to a date table for grouping purposes. As individual measure groups these work brilliantly, however, I've now been asked to "stitch" together the Sales and the forecasts based on the logic that you take the sales up to the start of the forecast (which is defined as a field we store in the DB imaginatively called "Forecast Start Date")that is:At forecast iteration FC1 the full year (by month) is:Sum of sales before the forecast startsMonth: Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|OctSales: 1 | 2 | 3 | 4 | 3 | 6 |FC1: 0 | 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5FC2: 0 | 0 | 0 | 0 | 0 | 0 | 3 | 4 | 5 | 6 |cumulated to read:Month: Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct |FC1: 1 | 2 | 3 | 4 | 3 | 1 | 2 | 3 | 4 | 5 | FC2: 1 | 2 | 3 | 4 | 3 | 6 | 3 | 4 | 5 | 6 |Then there is a requirement to summate "that which is in the past" - so, using another member from the "Date" hierarchy called "YMD" we wish to calculate the running total per FC1 and FC2 to that point in time. ie if I set the date to be 1st August, I would expect YTD to be sum Jan through 31st July , YTG to be 1st August through end of year and The full year to be YTD + YTGFor ITem 1, Customer 1 in "outers"Month: Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct | YTD| YTG | Full Year |FC1: 1 | 2 | 3 | 4 | 3 | 1 | 2 | 3 | 4 | 5 | 16 | 12 | 28 |FC2: 1 | 2 | 3 | 4 | 3 | 6 | 3 | 4 | 5 | 6 | 22 | 15 | 37 |or in "inners"Month: Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct | YTD| YTG | Full Year |FC1: 10 | 20| 30| 40| 30 | 10 | 20| 30| 40 | 50 | 160| 120| 280 |FC2: 10 | 20| 30| 40| 30 | 60 | 30| 40| 50 | 60 | 220| 150| 370 |Can anyone give me any pointers on how to achieve this? I've no idea where to even start!Many thanksTattysnuc
↧
Full year / YTD & YTG and stitching together different measure groups to make one continuous version
↧