Forum Discussion
Forecast From Selected Year
Hi Experts,
I have a revenue data from 2017 to 2030. However I want to select a specific year and calculate revenue increased per year.
Example if I take 2021 as a base year with sales and want to calculate yearly increase of 7% each year, that is in 2022 7% increase of 2021 and in 2023 7 % increase of 2022. This calculation of increase each year should continue untill 2030 as a forecast.
How can I achieve this?
| Year | Revenue |
| 2017 | 1000 |
| 2018 | 1500 |
| 2019 | 1750 |
| 2020 | 1100 |
| 2021 | 1850 |
| 2022 | 2050 |
| 2023 | 2025 |
| 2024 | 1075 |
| 2025 | 2000 |
| 2026 | 2050 |
| 2027 | 2100 |
| 2028 | 2150 |
| 2029 | 2200 |
| 2030 | 2250 |
- Anonymous2 years ago
Hi Anonymous , bhanu_gautam, thank you for your prompt reply!
For your requirements, please try as follows:
- Create a separate calculated table containing all year values:
YearsTable = DISTINCT('Table'[Year])
- Then create a slicer and drag it to the slicer field:
- Next, create a measure to calculate yearly increase of 7% each year from selected year:
Sales Forecast = VAR SelectedYear = SELECTEDVALUE(YearsTable[Year])
VAR StartRevenue =CALCULATE(
MAX('Table'[Revenue]),
FILTER('Table', 'Table'[Year] = SelectedYear)
)
VAR CurrentYear = MAX('Table'[Year])
VAR PreviousForecast = CALCULATE(
MAX('Table'[Revenue]),
FILTER(ALL('Table'), 'Table'[Year] = CurrentYear - 1)
)
RETURN
IF(
ISBLANK(SelectedYear),
MAX('Table'[Revenue]),
IF(
CurrentYear = SelectedYear,
StartRevenue,
IF(
CurrentYear > SelectedYear,
PreviousForecast * 1.07,
MAX('Table'[Revenue])
)))Test result for your reference:
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- bhanu_gautam
Super User
Anonymous , You can use paramteres for this
Click on "New Parameter" and create a parameter for the base year. Name it something like "BaseYearParameter".
Set the data type to "Whole Number" and specify the range of years (e.g., from 2017 to 2030).Create a new table for forecasted value
ForecastedRevenue =
VAR BaseYear = SELECTEDVALUE(BaseYearParameter[BaseYearParameter])
VAR BaseRevenue = CALCULATE(SUM('Revenue'[Revenue]), 'Revenue'[Year] = BaseYear)
VAR GrowthRate = 0.07
RETURN
ADDCOLUMNS(
FILTER(
GENERATESERIES(BaseYear, 2030, 1),
[Value] > BaseYear
),
"Forecasted Revenue",
BaseRevenue * POWER(1 + GrowthRate, [Value] - BaseYear)
)Add a slicer visual to your report.
Add the "BaseYearParameter" to the slicerCreate a new line chart or any other visual to display the forecasted revenue.
Add the "Year" column from the "ForecastedRevenue" table to the X-axis.
Add the "Forecasted Revenue" column to the Y-axis.- AnonymousNot applicable
Hello bhanu_gautam
I am receiving error message while creating new table in DAXThe arguments in the GenerateSeries function cannot be empty.I think it is because of selectedvalue function. Is there any other way to solve it.
Thank you for help.
- AnonymousNot applicable
Hi Anonymous , bhanu_gautam, thank you for your prompt reply!
For your requirements, please try as follows:
- Create a separate calculated table containing all year values:
YearsTable = DISTINCT('Table'[Year])
- Then create a slicer and drag it to the slicer field:
- Next, create a measure to calculate yearly increase of 7% each year from selected year:
Sales Forecast = VAR SelectedYear = SELECTEDVALUE(YearsTable[Year])
VAR StartRevenue =CALCULATE(
MAX('Table'[Revenue]),
FILTER('Table', 'Table'[Year] = SelectedYear)
)
VAR CurrentYear = MAX('Table'[Year])
VAR PreviousForecast = CALCULATE(
MAX('Table'[Revenue]),
FILTER(ALL('Table'), 'Table'[Year] = CurrentYear - 1)
)
RETURN
IF(
ISBLANK(SelectedYear),
MAX('Table'[Revenue]),
IF(
CurrentYear = SelectedYear,
StartRevenue,
IF(
CurrentYear > SelectedYear,
PreviousForecast * 1.07,
MAX('Table'[Revenue])
)))Test result for your reference:
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.