Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

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)

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,

 

 

 

 

5 Replies

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    sameperiodlastyear is a date function therefore it needs a date.

     

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

  • v-alq-msft's avatar
    v-alq-msft
    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.