/Forecast_Seasonality_1.dax Secret
Created
May 28, 2022 18:02
Star
You must be signed in to star a gist
Simple DAX forecast distribution with seasonality: https://wp.me/p6lgsG-2tS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SumForecast = | |
VAR _previousMonth = | |
CALCULATE ( | |
MAX ( 'Date'[Year Month Number] ), -- Must be the column that is connected to the Forecast-table | |
REMOVEFILTERS ( 'Date' ), | |
'Date'[Date] = TODAY () | |
) - 1 | |
VAR _latestYTD = | |
CALCULATE ( | |
[YTD SumSales], | |
REMOVEFILTERS ( 'Date' ), | |
'Date'[Year Month Number] = _previousMonth | |
) | |
VAR _cumulPercentage = | |
CALCULATE ( | |
[YTD SumPercentage], | |
REMOVEFILTERS ( 'Date' ), | |
'Date'[Year Month Number] = _previousMonth | |
) | |
VAR _amountForTotalYear = | |
DIVIDE ( _latestYTD, _cumulPercentage ) | |
VAR _result = | |
SUMX ( | |
'Forecast', | |
VAR _isPlanningMonth = | |
( CALCULATE ( MAX ( 'Date'[Year Month Number] ) ) > _previousMonth ) | |
VAR _relevantYTD = | |
IF ( _isPlanningMonth, _amountForTotalYear * Forecast[ % Forecast], [SumSales] ) | |
RETURN | |
_relevantYTD | |
) | |
RETURN | |
_result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment