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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

Dax SamePeriodLast year without dates

Hi all,

 

I'm trying to get the sum of the sales in a table using the function sameperiodlastyear but, the question here is, is it possible use the sameperiodlastyear function with out dates?  I have the follwing scenario:

 

A fat table with data and a column named Ejercicio/Período (Is not a date is more like Period could be more that 12 months)

tablaFat.PNG

and also i have a "master date table":

tablaPeriodo.PNG

The problem that i have is when I use the sameperiodlastyear is saying that must be a date.

Do you know this can be solve?

 

thanks,

 

 

 

 

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Function sameperiodlastyear returns a table that contains a column of dates shifted one year back in time from the dates in the specified dates column, in the current context. For further information, you may refer to the official document . 

 

Typically, your data model will contain a calendar table. In fact, it is usually better to aggregate data
by year and month using columns of a calendar table (containing one row for each day) instead
of extracting the date parts from a single column of type date or datetime in calculated columns.
There are a few reasons for this choice. You obtain a model wherein all date attributes are included
in a separate table making it easier to browse data using a generic client, and you can use special
DAX functions that perform time intelligence calculations. Moreover, most of the time intelligence
functions require a separate Date table to work correctly.

 

You may also refer what is suggested by @amitchandak . It may help.

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

vanessafvg
Super User
Super User

sameperiodlastyear is a date function therefore it needs a date.

 

either add a date to your table which should be fairly easy to create?   





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

@vanessafvg thanks vanessa. That's the point, there is no Month 13 or 14 and is it possible that in my dataset appear because is not a date , is a period of the year.

Refer to my blog on

: https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...

Also, refer to how rank can help you get a prior period this for the week but can be true for any custom period.

 

https://www.dropbox.com/s/d9898a48e76wmvl/sales_analytics_weekWise.pbix?dl=0

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

@Anonymous ,Does the above reply helps. if you need more help make me @

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors