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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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))
User | Count |
---|---|
98 | |
76 | |
74 | |
49 | |
26 |