Forum Discussion

metcala's avatar
metcala
Icon for Helper III rankHelper III
2 years ago
Solved

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

 

ProjectMonthCost
A31/1/24100
A29/2/24200
A31/3/24150
B31/1/24100
B29/2/24100
B31/3/2475

 

Forecast

 

ProjectMonthCost
A31/1/24200
A29/2/24200
A31/3/24200
A30/4/24200
A31/5/24200
.........
B31/1/24100
B29/2/24100
B31/3/24100
B30/4/24100
B31/5/24100
.........

 

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?

 

Project31/1/2429/2/2431/3/2430/4/2431/5/24...
A100200150200200...
B10010075100100...

 

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

  • 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
    __Display

     

     

    As 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 Thanks so much for the quick reply that's really helpful.

     

    What would be the best way to create the project dimension table? Every project will have a forecast so is there an easy way to just create a table using unique values from the forecast table project column?

  • 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.