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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
BI3N
Frequent Visitor

Two year data comparison - please help

Hi,

 

I have data in one single spreadsheet for the year 2017 and 2018 (Adding 2019 later). 

I want a line or Bar chart which compares two years of commission data in one visualization. 

However, I'm getting the following chart which separates year as below.

 

 

new.PNG

 

 

ideally, I would want a chart like below.

 

new 2.PNG

 

 

I'm frustrated as I did two separate spreadsheets as well and it didn't work as X-axis which has months didn't sort accordingly. so I'm trying a single spreadsheet and still cannot solve this issue.

Isn't this basic to data. I can't even find any solution in the community or youtube. Please, can someone help me?

3 REPLIES 3
jtownsend21
Responsive Resident
Responsive Resident

I would create a column for year using the following: 

Year = Year(Date)

Then in the date hierarchy just put in month, and put the year in on the legend. 

 

If the months are not sorting properly, you can create a column for the month number using  the following: 

MonthNumber = 
FORMAT(
    [Date],
    "M"
)

And then use the Sort by Column fuction on the modeling tab. (shortcut ALT, M, S) and sort by the new Month Number column. 

Anonymous
Not applicable

Take a look at this post as it talks about how to set this all up:

https://community.powerbi.com/t5/Desktop/Need-help-creating-YTD-and-LYTD-and-make-Index-as-Card/m-p/...

 

But one thing that isnt in that post, is the formula for Total Sales of the last period :

Total Sales Last Period = CALCULATE( [Total Sales], SAMEPERIODLASTYEAR( DimCalendar[Date] ))

Chart Sales of Last Period.png

Hi 

Thank you for your reply. 

I have found a different solution. i willl share if anyone needed.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.