Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi community,
Looking for help to create a measure to calculate a YTD number for a SAMEPERIODLASTYEAR.
Example dataset attached for reference, this is in use within the model.
My challenge is as follows:
Can you help?
Thanks for your support!
Solved! Go to Solution.
Try like this with date Calendar
This Year =
var _max = maxx('Sales','Sales'[Date])
var _min = date(year(_max),1,1)
return
CALCULATE(SUM('Sales'[Sales]), FILTER(all('Date'), 'Date'[Date]<=_max && 'Date'[Date]>=_min))
last Year =
var _max1 = maxx('Sales','Sales'[Date])
var _max = date(year(_max1)-1,month(_max1),day(_max1))
var _min = date(year(_max),1,1)
return
CALCULATE(SUM('Sales'[Sales]), FILTER(all('Date'), 'Date'[Date]<=_max && 'Date'[Date]>=_min))
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin
Hi @Anonymous ,
Please try the dax below:
Previous_YTD = CALCULATE([YTD] , DATEADD(Sheet7[date],-1,YEAR))
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your assistance, Liang.
Try like this with date Calendar
This Year =
var _max = maxx('Sales','Sales'[Date])
var _min = date(year(_max),1,1)
return
CALCULATE(SUM('Sales'[Sales]), FILTER(all('Date'), 'Date'[Date]<=_max && 'Date'[Date]>=_min))
last Year =
var _max1 = maxx('Sales','Sales'[Date])
var _max = date(year(_max1)-1,month(_max1),day(_max1))
var _min = date(year(_max),1,1)
return
CALCULATE(SUM('Sales'[Sales]), FILTER(all('Date'), 'Date'[Date]<=_max && 'Date'[Date]>=_min))
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin
Thank you for your assistance, amitchandak.
I accepted your response as the solution because it is allows additional flexibility to be adapted easily and logically for similar circumstances and other columns in my situation. The other responses elsewhere were also very helpful and worked too - thanks to the other users for their input.
Hi @Anonymous
Sure, you can combine time intelligence functions like below.
Sales Last Year To Date =
CALCULATE(
[Sales], --your measure
DATESYTD(
SAMEPERIODLASTYEAR( 'Calendar'[Date] ) --date from your date dimension / calendar table
)
)
Thank you for your assistance, Mariusz.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
101 | |
82 | |
79 | |
66 |
User | Count |
---|---|
120 | |
110 | |
94 | |
81 | |
77 |