cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kashsks
Regular Visitor

Getting Last Year Sales grouped by Store

I am having an issue with with displaying last year sales data that are grouped by their respective store locations.

 

I created the Measure LY Total Sales:

 

LY Total Sales = CALCULATE(sum(DailySales[Sales]),SAMEPERIODLASTYEAR(DailySales[DateKey]))

But when I used it in a Column chart distributed by the store location I get a chart that is the same level across all stores. Is there a way to properly represent each store's last year sales?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Getting Last Year Sales grouped by Store

Hi Kashsks,

 

In your scenario, the issue can be caused by that the chart values are grouped for each X-axis group instance. You need to add a filter within the measure to filter corresponding values for each X-axis instance. Please follow the steps below:

 

1. Create two test tables.

Sales Record 2015:

Capture.PNG

Sales Record 2016:

Capture2.PNG

 

 

2. Add a measure to Sales Record 2016 table and create the chart.

 

LY Total Sales = CALCULATE(SUM('Sales Record 2015'[Amount]),SAMEPERIODLASTYEAR('Sales Record 2016'[Date]),'Sales Record 2015'[Company]=VALUES('Sales Record 2016'[Company]))

 

 Capture4.PNG

 

 Capture5.PNG

 

 

If above is not help, could you provide the data struct about your tables?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

2 REPLIES 2
Community Support
Community Support

Re: Getting Last Year Sales grouped by Store

Hi Kashsks,

 

In your scenario, the issue can be caused by that the chart values are grouped for each X-axis group instance. You need to add a filter within the measure to filter corresponding values for each X-axis instance. Please follow the steps below:

 

1. Create two test tables.

Sales Record 2015:

Capture.PNG

Sales Record 2016:

Capture2.PNG

 

 

2. Add a measure to Sales Record 2016 table and create the chart.

 

LY Total Sales = CALCULATE(SUM('Sales Record 2015'[Amount]),SAMEPERIODLASTYEAR('Sales Record 2016'[Date]),'Sales Record 2015'[Company]=VALUES('Sales Record 2016'[Company]))

 

 Capture4.PNG

 

 Capture5.PNG

 

 

If above is not help, could you provide the data struct about your tables?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

Kashsks
Regular Visitor

Re: Getting Last Year Sales grouped by Store

Hi Xioxin,

 

Your suggestion worked perfectly! Thank you so much!

 

I didn't create 2 tables (since both this year and last year's data sit on the same table), but the concept should be just the same:

 

LY Total Sales = CALCULATE(SUM(DailySales[Sales]), SAMEPERIODLASTYEAR(DailySales[trxdate]),DailySales[STORE] = VALUES(DailySales[STORE]))

Cheers~

 

 

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors