Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
75 | |
63 | |
51 | |
48 |
User | Count |
---|---|
204 | |
86 | |
62 | |
59 | |
56 |