Forum Discussion
Future Month YTD calculation
- Anonymous2 years ago
Hi Anonymous ,
Thanks for the reply from amitchandak .
Here is the sample data I created:
Date
Sales
1/1/2024
100
2/1/2024
200
3/1/2024
150
4/1/2024
250
5/1/2024
160
6/1/2024
240
7/1/2024
320
8/1/2024
280
9/1/2024
420
10/1/2024
310
11/1/2024
180
12/1/2024
280
1/1/2024
100
2/1/2024
200
3/1/2024
150
4/1/2024
250
5/1/2024
160
6/1/2024
240
7/1/2024
320
8/1/2024
280
9/1/2024
420
10/1/2024
310
11/1/2024
180
12/1/2024
280
Create a disconnected date table and create a month column in both the date table and the master table:
Date = CALENDAR(MIN('Sales'[Date]),MAX('Sales'[Date])) Month = MONTH('Date'[Date]) Month = MONTH('Sales'[Date])Create a measure in the Sales table:
Accumulated Sales = VAR _curMon = MAX('Date'[Month]) VAR _staMon = _curMon + 2 VAR _endMon = _staMon + 5 RETURN CALCULATE( SUM('Sales'[Sales]), FILTER( ALL('Sales'), 'Sales'[Month] >= _staMon && 'Sales'[Month] <= _endMon ))This measure calculates the Sum of Sales from the next two months to the next six months of the current month.
The visual effect of the page is as follows:
If your problem cannot be solved successfully, please provide me with sample data or pbix file. Please be careful to erase sensitive information and do not log in to your account when uploading the pbix file in Power BI Desktop.
The pbix file is attached.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot! - Anonymous2 years ago
Hi Anonymous
Thanks for the solution.
There is bit change in the calculation as below code,
Spend Optimize month range 2-6 =var selected_month = MAX('Automated Monthly'[Month-Year])var futureTwoMonths = EOMONTH(selected_month,1) + 1var futureSixMonths = EOMONTH(futureTwoMonths,5)var result = CALCULATE(SUM('Automated Monthly'[Optimized Spend]),'Automated Monthly'[Month-Year] >= futureTwoMonths && 'Automated Monthly'[Month-Year] <= futureSixMonths)RETURN resultTo create var futureTwoMonths we have to use +1 at the end
that time works for me.Thank u so much..!!
Hi Anonymous ,
Thanks for the reply from amitchandak .
Here is the sample data I created:
|
Date |
Sales |
|
1/1/2024 |
100 |
|
2/1/2024 |
200 |
|
3/1/2024 |
150 |
|
4/1/2024 |
250 |
|
5/1/2024 |
160 |
|
6/1/2024 |
240 |
|
7/1/2024 |
320 |
|
8/1/2024 |
280 |
|
9/1/2024 |
420 |
|
10/1/2024 |
310 |
|
11/1/2024 |
180 |
|
12/1/2024 |
280 |
|
1/1/2024 |
100 |
|
2/1/2024 |
200 |
|
3/1/2024 |
150 |
|
4/1/2024 |
250 |
|
5/1/2024 |
160 |
|
6/1/2024 |
240 |
|
7/1/2024 |
320 |
|
8/1/2024 |
280 |
|
9/1/2024 |
420 |
|
10/1/2024 |
310 |
|
11/1/2024 |
180 |
|
12/1/2024 |
280 |
Create a disconnected date table and create a month column in both the date table and the master table:
Date = CALENDAR(MIN('Sales'[Date]),MAX('Sales'[Date]))
Month = MONTH('Date'[Date])
Month = MONTH('Sales'[Date])
Create a measure in the Sales table:
Accumulated Sales =
VAR _curMon = MAX('Date'[Month])
VAR _staMon = _curMon + 2
VAR _endMon = _staMon + 5
RETURN
CALCULATE(
SUM('Sales'[Sales]),
FILTER(
ALL('Sales'),
'Sales'[Month] >= _staMon
&&
'Sales'[Month] <= _endMon
))
This measure calculates the Sum of Sales from the next two months to the next six months of the current month.
The visual effect of the page is as follows:
If your problem cannot be solved successfully, please provide me with sample data or pbix file. Please be careful to erase sensitive information and do not log in to your account when uploading the pbix file in Power BI Desktop.
The pbix file is attached.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi Anonymous
Thanks for the solution.
There is bit change in the calculation as below code,
that time works for me.