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

Top Solution Authors