The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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)
and also i have a "master date table":
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,
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.
sameperiodlastyear is a date function therefore it needs a date.
either add a date to your table which should be fairly easy to create?
Proud to be a Super User!
@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
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