Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
XaviOV
Helper V
Helper V

Data current year vs last year Line and clustered chart and manage relationship

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

Anual actual vs anterior.png

 

Anual actual vs anterior1.png

 

Anual actual vs anterior2.png

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@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))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

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.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@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))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.