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

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.

Reply
mshamsiev
Helper I
Helper I

Comparing 2 Sets of Data on Line Graphs

Hi all,

 

I'm trying to compare volume of requests across two years and chart in on a line graph. Eg. line graph comparing Mar16-Mar17 on one line and Mar15-Mar16 on the secondary line. Any idea how I can do this?

 

Thanks,

Mike 

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @mshamsiev,


I'm trying to compare volume of requests across two years and chart in on a line graph. Eg. line graph comparing Mar16-Mar17 on one line and Mar15-Mar16 on the secondary line. Any idea how I can do this?


If I understand you correctly, you should be able to make use of SAMEPERIODLASTYEAR Function (DAX) to create a new measure to do your calculations for the same period last year, which should be easier in your scenario. Smiley Happy

 

For example, if you want to compare the total sales of Mar16-Mar17 and Mar15-Mar16, then you can show both [Total Sales] and [PY Sales] as the Values for the Line Chart, and use a Slicer to filter the date to Mar16-Mar17.

Total Sales = SUM(Sales[Revenue])
LY Sales = CALCULATE([Total Sales],SAMEPERIODLASTYEAR('Date'[Date]))

 

Regards

View solution in original post

4 REPLIES 4
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @mshamsiev,


I'm trying to compare volume of requests across two years and chart in on a line graph. Eg. line graph comparing Mar16-Mar17 on one line and Mar15-Mar16 on the secondary line. Any idea how I can do this?


If I understand you correctly, you should be able to make use of SAMEPERIODLASTYEAR Function (DAX) to create a new measure to do your calculations for the same period last year, which should be easier in your scenario. Smiley Happy

 

For example, if you want to compare the total sales of Mar16-Mar17 and Mar15-Mar16, then you can show both [Total Sales] and [PY Sales] as the Values for the Line Chart, and use a Slicer to filter the date to Mar16-Mar17.

Total Sales = SUM(Sales[Revenue])
LY Sales = CALCULATE([Total Sales],SAMEPERIODLASTYEAR('Date'[Date]))

 

Regards

mshamsiev
Helper I
Helper I

Bump

Add a column to your data table for the year (with your custom year range i.e. Mar '15 - Mar '16). Then, just add this field to your chart as the Legend value.

Hey @dkay84_PowerBI,

 

Cheers for the reply 🙂 Is that through a DAX function? 

 

-Mike 

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.