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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors