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
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
v-shex-msft
Community Support
Community Support

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
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

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
If this post helps, please consider accept as solution to help other members find it more quickly.

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
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.