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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors