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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Use Bar Chart to Show Year-Over-Year Comparison

I have an Excel table with the calendar year 2018 (Jan-Dec) and 2019 (Jan-Dec) listed in Column A; total of 24 rows.    In column B, I have a list of #'s next to each of these months.    How can I create a bar chart that will show January 2018 and January 2019 together side-by-side; February 2018 and February 2019 side-by-side, etc.     Basically, I want to compare each of the individual months from 2018 with the previous 2019 months.

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hello @creynolds ,

According to my understanding, you want to compare with the same monthIt's worth two years, isn't it?

Here's my data sample:

8.19.7.png

You can use the following formula:

monthColumn =
YearMonth[A]. [Month]
yearColumn =
YEAR ( 'YearMonth'[A] )

My stacked bar chart and bar chart with groups look like this:

8.19.8.jpg8.19.9.PNG

Is the result what you want? If you have any questions, upload some data samples and expected output.

Please mask sensitive data before uploading.

Best regards

Eyelyn Qin

View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hello @creynolds ,

According to my understanding, you want to compare with the same monthIt's worth two years, isn't it?

Here's my data sample:

8.19.7.png

You can use the following formula:

monthColumn =
YearMonth[A]. [Month]
yearColumn =
YEAR ( 'YearMonth'[A] )

My stacked bar chart and bar chart with groups look like this:

8.19.8.jpg8.19.9.PNG

Is the result what you want? If you have any questions, upload some data samples and expected output.

Please mask sensitive data before uploading.

Best regards

Eyelyn Qin

Anonymous
Not applicable

Thanks much!
amitchandak
Super User
Super User

@Anonymous , If you have a date or create a date you can use time intelligence. Or you have to use the rank way.

Create date from month year

New column

Date = "01-" & [Month] & "-" & [Year] // when month is Jan or January format

Date = Date([Year],[Month],01) // when month is a number

 

Now try MTD, previous month

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
previous month value =  CALCULATE(sum('table'[total hours value]),previousmonth('Date'[Date]))
Last year same month value =  CALCULATE(sum('table'[total hours value]),previousmonth(dateadd('Date'[Date],-12,MONTH)))

 

Power BI — MTD
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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