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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.