Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Sure, here is a clear and professional English translation of the question:
At work, I was asked to create a metric called Closing Forecasting, which can be calculated at either the yearly or monthly level.
The calculation is based on the average sales up to a selected month, projected over the remaining months of the year.
For example:
If March 2025 is selected, the yearly Closing Forecasting is calculated by:
Taking the average sales of January, February, and March, then multiplying it by the number of remaining months in the year (9 months).
If May is selected, the calculation becomes:
Average sales of the first five months × remaining months (7 months).
The calculation is based on the average sales up to a selected day, projected over the remaining days of the month.
For example:
If April 10 is selected, the monthly Closing Forecasting is calculated as:
Average sales of the first 10 days × the remaining days of the month (20 days).
How can this calculation be implemented in a dynamic way so that it automatically adjusts based on the selected month or day?
A Power BI (DAX) example would be highly appreciated.
Thank you very much for your support.
Solved! Go to Solution.
Closing Forecast (Year) =
VAR MaxSelectedDate =
MAX ( 'Date'[Date] )
VAR Y =
YEAR ( MaxSelectedDate )
VAR LastSelectedMonth =
MONTH ( MaxSelectedDate )
VAR SalesToMonth =
CALCULATE (
[Sales],
FILTER (
ALL ( 'Date'[Date] ),
YEAR ( 'Date'[Date] ) = Y
&& MONTH ( 'Date'[Date] ) <= LastSelectedMonth
)
)
VAR AvgMonthlySales =
DIVIDE ( SalesToMonth, LastSelectedMonth )
VAR RemainingMonths =
12 - LastSelectedMonth
RETURN
AvgMonthlySales * RemainingMonths
Closing Forecast (Month) =
VAR MaxSelectedDate =
MAX ( 'Date'[Date] )
VAR MonthStart =
DATE ( YEAR ( MaxSelectedDate ), MONTH ( MaxSelectedDate ), 1 )
VAR DaysInMonth =
DAY ( EOMONTH ( MaxSelectedDate, 0 ) )
VAR SelectedDay =
DAY ( MaxSelectedDate )
VAR SalesToDay =
CALCULATE (
[Sales],
DATESBETWEEN ( 'Date'[Date], MonthStart, MaxSelectedDate )
)
VAR AvgDailySales =
DIVIDE ( SalesToDay, SelectedDay )
VAR RemainingDays =
DaysInMonth - SelectedDay
RETURN
AvgDailySales * RemainingDays
If you want a single measure that changes based on what’s on the visual:
Closing Forecast =
IF (
ISINSCOPE ( 'Date'[Date] ),
[Closing Forecast (Month)],
[Closing Forecast (Year)]
)
Closing Forecast (Year) =
VAR MaxSelectedDate =
MAX ( 'Date'[Date] )
VAR Y =
YEAR ( MaxSelectedDate )
VAR LastSelectedMonth =
MONTH ( MaxSelectedDate )
VAR SalesToMonth =
CALCULATE (
[Sales],
FILTER (
ALL ( 'Date'[Date] ),
YEAR ( 'Date'[Date] ) = Y
&& MONTH ( 'Date'[Date] ) <= LastSelectedMonth
)
)
VAR AvgMonthlySales =
DIVIDE ( SalesToMonth, LastSelectedMonth )
VAR RemainingMonths =
12 - LastSelectedMonth
RETURN
AvgMonthlySales * RemainingMonths
Closing Forecast (Month) =
VAR MaxSelectedDate =
MAX ( 'Date'[Date] )
VAR MonthStart =
DATE ( YEAR ( MaxSelectedDate ), MONTH ( MaxSelectedDate ), 1 )
VAR DaysInMonth =
DAY ( EOMONTH ( MaxSelectedDate, 0 ) )
VAR SelectedDay =
DAY ( MaxSelectedDate )
VAR SalesToDay =
CALCULATE (
[Sales],
DATESBETWEEN ( 'Date'[Date], MonthStart, MaxSelectedDate )
)
VAR AvgDailySales =
DIVIDE ( SalesToDay, SelectedDay )
VAR RemainingDays =
DaysInMonth - SelectedDay
RETURN
AvgDailySales * RemainingDays
If you want a single measure that changes based on what’s on the visual:
Closing Forecast =
IF (
ISINSCOPE ( 'Date'[Date] ),
[Closing Forecast (Month)],
[Closing Forecast (Year)]
)
Dear @cengizhanarslan , hope you are well
Thank you for your help, my brother, and apologies for the earlier mistake in explaining the calculation.
I would like to clarify the correct calculation as follows:
If March 2025 is selected, the yearly Closing Forecasting value is calculated by:
Taking the average sales of January, February, and March, then multiplying this average by the total number of months in the year (12 months).
If April 10, 2025 is selected, the monthly Closing Forecasting value is calculated as:
The average sales of the first 10 days multiplied by the total number of days in April (30 days).
How can this calculation be made dynamic, so that it automatically adjusts based on the selected month or day?
Thank you very much for your support.
I am not sure how you data model looks like.
i have create a very simple example.
| 2025/1/1 | 1 | 202501 |
| 2025/2/1 | 2 | 202502 |
| 2025/3/1 | 3 | 202503 |
| 2025/4/1 | 4 | 202504 |
| 2025/4/10 | 5 | 202504 |
| 2025/5/1 | 6 | 202505 |
Proud to be a Super User!
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 58 | |
| 53 | |
| 40 | |
| 17 | |
| 16 |
| User | Count |
|---|---|
| 114 | |
| 107 | |
| 41 | |
| 34 | |
| 25 |