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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
iluvcoding_91
Helper I
Helper I

Same period last year calculation (include rows where current year sales is $0)

Hello, I have a FACT table where I'm trying to sum up the current year sales and prior year sales (side by side in a matrix chart) using the sameperiodlastyear DAX function. I want the matrix to show ALL records from both years (i.e., if sales for a particular country were generated last year, but not in the current year, I want those records displayed as well). The problem is the sameperiodlastyear function will only retrieve records from the prior year ONLY IF current year sales exists. Otherwise, all prior years records that don't exist in the current year will be filtered out. Any idea on how I can modify the measures to include all sales from both years?

iluvcoding_91_0-1657150464378.png

 

1 ACCEPTED SOLUTION

Thanks, it was my data model that was not producing the correct result

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood correctly about your data model., but please check the below picture and the attached pbix file.

 

Untitled.png

 

Sales total sameperiodlastyear: =
CALCULATE (
    [Sales total current year:],
    SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks, it was my data model that was not producing the correct result

Hi, @iluvcoding_91 

If the issue is resolved, you can close this thread by marking the relevant reply as solution.

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.