Forum Discussion
Forecasting with Parameters from Historical Data
- 3 years ago
Step 1) Change the relationship so Calendar table will filter the fact_table.
Step 2) Create DateType column in Calendar table that holds an information if it's a forecast or actual value.
DataType = IF(CONTAINS(fact_table,fact_table[Year],[Year]),"Actual","Forecast")Step 3) Create a measure to calculate Growth Rate for future years based on slicers.Growth Rate - Dynamic = VAR __lastDateWithActual = CALCULATE(MAX('Calendar'[Year]),'Calendar'[DataType]="Actual") VAR __thisyear = MAX('Calendar'[Year]) VAR __GrowthRatePerDepartment = CALCULATE( AVERAGEX( VALUES(fact_table[Department]), SWITCH(fact_table[Department], "Business",Business[Business Value], "Science",Science[Science Value], "Technology",Technology[Technology Value], "Math",Math[Math Value], "History",History[History Value], 1) ), ALL('Calendar') ) VAR __compundGrowRate = CALCULATE( PRODUCTX(VALUES('Calendar'[Year]), 1 + __GrowthRatePerDepartment), 'Calendar'[Year] <= __thisyear, 'Calendar'[Year] > __lastDateWithActual ) RETURN __compundGrowRateStep 4) Create a measure that calculates value with Growth Rate:
Value with Growth Rate = var __lastActual = CALCULATE(LASTNONBLANKVALUE('Calendar'[Year],[Value]),REMOVEFILTERS('Calendar')) return SUMX( VALUES('Calendar'[Year]), IF(MAX('Calendar'[DataType])="Actual",[Value],__lastActual * [Growth Rate - Dynamic]) )
Step 5) Feel free to leave a like & kudos 🙂
Results for all Departments:
Results for Math only:
PBIX FILE: https://we.tl/t-oFkef8HvHK
Please provide sample data that covers your issue or question completely.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
- datagamble433 years agoFrequent Visitor
Hi lbendlin,
Here is a table of sample data:
Year Department Category Value 2020 Business HUMAN 4300 2020 Science STEM 4900 2020 Math STEM 3300 2020 Technology TECH 2500 2020 History HUMAN 1000 2021 Business HUMAN 4500 2021 Science STEM 4800 2021 Math STEM 3200 2021 Technology TECH 2000 2021 History HUMAN 700 2022 Business HUMAN 5000 2022 Science STEM 4500 2022 Math STEM 3000 2022 Technology TECH 3500 2022 History HUMAN 1100 2023 Business HUMAN 5000 2023 Science STEM 4500 2023 Math STEM 3000 2023 Technology TECH 3500 2023 History HUMAN 1100 2024 Business HUMAN 5000 2024 Science STEM 4500 2024 Math STEM 3000 2024 Technology TECH 3500 2024 History HUMAN 1100 In addition, here is the BI file that I loaded in and created parameters with, as well as the excel file which contains the expected outcome on sheet:
BI FILE
https://1drv.ms/u/s!Aq06tAa7wTh3in7lcaaBRwjc0wJZ?e=KtdQ9I
EXCEL FILE
https://1drv.ms/x/s!Aq06tAa7wTh3in0FAXge_jmvKTo8?e=PIGC4y
To reword the issue -- When changing the dynamic parameter filter, the growth is based on the 2022 year and not the expected year over year growth, as seen below.