Forum Discussion
Finance Forecast using DAX
- 8 years ago
Hi Anonymous
Hope it helps
Here are the steps
Step#1 Determine the First and Last Years with Actual data using these MEASURES
FirstYear = FIRSTNONBLANK ( ALL ( YearTable[Year] ), CALCULATE ( SUM ( MeasureTable[Revenue] ) ) )LastYear = LASTNONBLANK ( ALL ( YearTable[Year] ), CALCULATE ( SUM ( MeasureTable[Revenue] ) ) )Step#2 Determine the CAGR
CAGR = VAR Lastyear = [LastYear] VAR Firstyear = [FirstYear] VAR No_of_Years = [LastYear] - [FirstYear] RETURN POWER ( DIVIDE ( CALCULATE ( SUM ( MeasureTable[Revenue] ), YearTable[Year] = Lastyear ), CALCULATE ( SUM ( MeasureTable[Revenue] ), YearTable[Year] = Firstyear ) ), 1 / No_of_Years ) - 1Step#3: Get the Forecast
Forecast = VAR Lastyear = [LastYear] VAR No_of_Years = SELECTEDVALUE ( YearTable[Year] ) - [LastYear] RETURN IF ( SELECTEDVALUE ( YearTable[Year] ) > Lastyear, CALCULATE ( SUM ( MeasureTable[Revenue] ), YearTable[Year] = Lastyear ) * POWER ( ( 1 + [CAGR] ), No_of_Years ) )
Hi Anonymous
Hope it helps
Here are the steps
Step#1 Determine the First and Last Years with Actual data using these MEASURES
FirstYear =
FIRSTNONBLANK (
ALL ( YearTable[Year] ),
CALCULATE ( SUM ( MeasureTable[Revenue] ) )
)LastYear =
LASTNONBLANK (
ALL ( YearTable[Year] ),
CALCULATE ( SUM ( MeasureTable[Revenue] ) )
)
Step#2 Determine the CAGR
CAGR =
VAR Lastyear = [LastYear]
VAR Firstyear = [FirstYear]
VAR No_of_Years = [LastYear] - [FirstYear]
RETURN
POWER (
DIVIDE (
CALCULATE ( SUM ( MeasureTable[Revenue] ), YearTable[Year] = Lastyear ),
CALCULATE ( SUM ( MeasureTable[Revenue] ), YearTable[Year] = Firstyear )
),
1 / No_of_Years
)
- 1Step#3: Get the Forecast
Forecast =
VAR Lastyear = [LastYear]
VAR No_of_Years =
SELECTEDVALUE ( YearTable[Year] ) - [LastYear]
RETURN
IF (
SELECTEDVALUE ( YearTable[Year] ) > Lastyear,
CALCULATE ( SUM ( MeasureTable[Revenue] ), YearTable[Year] = Lastyear )
* POWER ( ( 1 + [CAGR] ), No_of_Years )
)
Hi,
This is a really interesting method and it sort of works for me but my results are a little off and I have some questions, if you don't mind:
- The first two measures in your Step 1 make sense to me as you are using a total revenues result to establish a CAGR (compound annual growth rate). However, wouldn't ALLSELECTED be a better function rather than ALL as we would only want results from the selected dates?
- If I want the historical total revenues calculated during the period I will use for the forecast, is FIRSTNONBLANK and LASTNONBLANK the best way to do this as then any null value in the historical data will then have a forecasted value created even though it is already in the past. For example, assuming today's date is Oct 2019:
| Month | Year | Total Revenue | Forecast |
| Jan | 2019 | 2 | |
| Feb | 2019 | 6 | |
| Mar | 2019 | 11 | |
| Apr | 2019 | 3 |
etc.
Wouldn't it be better to use MIN and MAX to get the total revenues and how would I get it to not forecast the blank months that are before the end date?
- My understanding of the the result from the two Step 1 measures, FirstYear and LastYear, are the total revenues for that given time period, correct, or in the context of the conventional CAGR calculation, the (End Value/Start Value)^(1/Periods)-1. But in Step 2, those measures are used to compute CAGR using the End Value (LastYear) - Start Value (FirstYear) to get the number of years (No_of_Years) variable. In this case, the No_of_Years variable (Period) will give the result of the total revenue of the End Value (LastYear) minus the Start Value (FirstYear) which won't be a period rather it will be the revenue amount. Is this correct? Shouldn't the Period be the first year minus the current year to get the number of years (the Period)?
- In Step 4, it seems to me that once again we are mixing the year number (2019) for the sum of the revenues for that year again and the same for the first year. Am I missing something or are we changing the meaning of the measures from the total revenues instead of the year number?
- I want to forecast my model beyond the end of the current year. What would it take to modify how far out this forecast will go?
I'm very sorry for the long winded question on an older post but I am trying to get it to work and it is giving me strange results (and errors in some instances).
Thanks so much in advance for chiming in!
Jeremy