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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi there,
I have a problem when I need to show the value of the current year and last year (same period) in "Line and grouped column chart", now I have a table with the date that I relate to the table of values that I need to calculate. The problem is that last year's value appears in January through December.
The graphic is relative date in this year.
Attached screenshots.
Regards,
Xavi
Solved! Go to Solution.
@XaviOV ,
Try like
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"),'Date'[Date]<=today()) //change end date of year
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,year),'Date'[Date]<=date(year(today())-1,month(today()),day(today())))
or something like this
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))
Hi @XaviOV ,
Do you try the formulas that amitchandak suggests? Have you resolved this problem? If yes, please accept the helpful answer as a solution. And welcome share your own solutions. More people will benefit here.
If you still need help, please share more details, like sample data and expected results. We will understand clearly.
@XaviOV ,
Try like
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"),'Date'[Date]<=today()) //change end date of year
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,year),'Date'[Date]<=date(year(today())-1,month(today()),day(today())))
or something like this
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))
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.