Forum Discussion
Forecast/Actuals based on current date
Hi there
I currently have two separate tables one containing actual costs by project by month and the other containing the forecast by project by month.
Actuals
| Project | Month | Cost |
| A | 31/1/24 | 100 |
| A | 29/2/24 | 200 |
| A | 31/3/24 | 150 |
| B | 31/1/24 | 100 |
| B | 29/2/24 | 100 |
| B | 31/3/24 | 75 |
Forecast
| Project | Month | Cost |
| A | 31/1/24 | 200 |
| A | 29/2/24 | 200 |
| A | 31/3/24 | 200 |
| A | 30/4/24 | 200 |
| A | 31/5/24 | 200 |
| ... | ... | ... |
| B | 31/1/24 | 100 |
| B | 29/2/24 | 100 |
| B | 31/3/24 | 100 |
| B | 30/4/24 | 100 |
| B | 31/5/24 | 100 |
| ... | ... | ... |
I am looking to create a table as below which uses actuals for previous months and forecast for current and future months. Currently the tables are not linked, assume I will need some sort of date table to link these and then a dax measure to populate the table?
| Project | 31/1/24 | 29/2/24 | 31/3/24 | 30/4/24 | 31/5/24 | ... |
| A | 100 | 200 | 150 | 200 | 200 | ... |
| B | 100 | 100 | 75 | 100 | 100 | ... |
Any help on this would be very much appreciated!!
metcala what is your backend source? If it is some SQL server, you can view it with the unique value, if not then you can easily do it in PQ, assuming the forecast table has all the projects.
- right click on the forecast table and click reference, it will duplicate the forecast table
- select project column, right-click, remove other columns
- select the project column, and right-click, select remove duplicates.
rename this table as you see fit and here you have a table with unique values of all the projects.
3 Replies
- parry2k
Super User
metcala you need two dimension tables, one date dimension, and the other project dimension. Project table will have unique project ids. Set the relationship of these new tables with the actual and forecast table on the respective column.
On matrix visual, use date from the date dimension, project from the project dimension, and add the following measure to use on the value. Tweak this measure as you see fit but this will get you started.
Measure = VAR __Actual = SUM ( ActualTable[Actual Column] ) VAR __Forecast = SUM ( ForecastTable[Forecast Column] ) VAR __Display = IF ( MAX ( 'Date Table'[Date] ) <= TODAY (), __Actual, __Forecast ) RETURN __DisplayAs a best practice, add a date dimension in your model and use it for time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools. Check the related videos on my YT channel
Add Date Dimension
Importance of Date Dimension
Mark date dimension as a date table - why and how?
Time Intelligence Playlist - parry2k
Super User
metcala what is your backend source? If it is some SQL server, you can view it with the unique value, if not then you can easily do it in PQ, assuming the forecast table has all the projects.
- right click on the forecast table and click reference, it will duplicate the forecast table
- select project column, right-click, remove other columns
- select the project column, and right-click, select remove duplicates.
rename this table as you see fit and here you have a table with unique values of all the projects.