cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerBINewbie81
New Member

Sales by Product: Current Year or Last Year

Hello,

Here is what I think is a simple question, but I can't seem to get it to work. I'm trying to use a table to show sales by product in this year and last year. The issue comes when I had sales last year but not this year.

 

The data is structured like this:

Year   Product   Sales

2021    A       50

2021    B       25

2021    C       100

2022    B         75

2022    C        100

But when I use CALCULATE([Sales],SAMEPERIODLASTYEAR('Calendar'[Date])), it drops product A since there are no sales this year.

 

 

Desired output is this:

Product20222021
A050
B7525
C100100

 

But instead, I get this:

Product20222021
B7525
C100100

 

Thanks in advance!

1 ACCEPTED SOLUTION

Given the volume of data, that isn't possible (what I showed was a very simplified view). However, I have found a work around in the way the source data is produced which makes it easier when I pull it into PBI.

 

Thanks!

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @PowerBINewbie81 ,

Please add 0 to the original formula of [Sales], like this.

 

Sales = SUM('Table'[Sales]) + 0

 

vcgaomsft_0-1669945524123.png

Table:

vcgaomsft_1-1669945549295.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Given the volume of data, that isn't possible (what I showed was a very simplified view). However, I have found a work around in the way the source data is produced which makes it easier when I pull it into PBI.

 

Thanks!

Helpful resources

Announcements
March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors