We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi Community..!!
My requirement is to calculate future YTD.
For Ex: Now we are in month of May 2024 , I need to calculated YTD starting from July month + 5 month
its need to start from July month why because , the requirement is like latest month (May) + 2 months = July month,
if we are in June month then it will start from August month like this... From August + 5 months = From August to Jan 2025
I have future Data.
Could anyone help me to resolve this.
Thanks in advance..!!
Solved! Go to Solution.
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,
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,
Hi @Anonymous
Thanks for the solution,
Here i am using slicer as a input for month
the month will be selected from slicer,
If i select Jan month in the slicer then the calculation will start from March to Aug
if i am using the below dax code shared by you
VAR _staMon = _curMon + 2 VAR _endMon = _staMon + 5
then it is showing emty result ,
if i use below code
@Anonymous , Assuming you are using a date table joined with date of your table
Try a measure like
Custom YTD =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max1)+1
var _max = eomonth(_max1,7)
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))
Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
Hi @amitchandak
You have calculated [net] in return field, what is the formula for the same.
and i am selecting month from slicer , hence in the calculation also, if the month i have selected in slicer is Jan then the calculation will be start from month March and till 6 month ie. March - August.
I need cumulative sum for the same.
Thanks
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 57 | |
| 38 | |
| 32 | |
| 18 | |
| 16 |
| User | Count |
|---|---|
| 66 | |
| 66 | |
| 40 | |
| 34 | |
| 25 |