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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Maikeru
Helper II
Helper II

SAMEPERIODLASTYEAR not displaying dimensions with no values in current year

Dear all,

 

I have a simple dataset of sales volume by customer accross multiple years.

When doing a Year-over-Year comparison by customer using SAMEPERIODLASTYEAR, PowerBI leaves out the rows which have no values in current year (in the below example customer C5)

 

Volume LastPeriod = CALCULATE(
    [Volume CurrentPeriod],
    SAMEPERIODLASTYEAR(Sales[Date])
)

 

 

The total is well calculated though.

I assume this has to do with the date slicer, but isn't there a way to work around this?

 

Best regards

Michael 

 

Image 10.png

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Maikeru , Please use date table for that.

 

Volume LastPeriod = CALCULATE(
    [Volume CurrentPeriod],
    SAMEPERIODLASTYEAR(Date[Date])
)

Refer

Power BI — YTD Questions — Time Intelligence 1–5
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
AllisonKennedy
Super User
Super User

You definitely need to use a DimDate table and you will solve this problem.
https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@amitchandak @AllisonKennedy 

Many thanks, this fixed the issue!

I usually use a separate calendar table, but this time I tried to simplify my model thinking the output would be the same.

I was wrong. Lesson learnt!

amitchandak
Super User
Super User

@Maikeru , Please use date table for that.

 

Volume LastPeriod = CALCULATE(
    [Volume CurrentPeriod],
    SAMEPERIODLASTYEAR(Date[Date])
)

Refer

Power BI — YTD Questions — Time Intelligence 1–5
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
AntrikshSharma
Super User
Super User

C2 and C3 do not have any values in 2019 so that is the correct behavior.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors