Forum Discussion

StephenK's avatar
StephenK
Resolver I
6 years ago

SAMEPERIODLASTYEAR expects a contiguous selection

Hello all,

 

I have the following measure: 

Dynamic Capacity SPLY = CALCULATE(SUM('Fact_Schedule'[DynamicAdjustedSlots]),SAMEPERIODLASTYEAR('Date Dim'[Date]))-[DynamicPTO]

I'm getting the following error message: 
 
 
 
 
 
 
 
 
 
My date dim is a calendar table and has contiguous unduplicated dates. I'm not sure what the problem is.
Here is a screenshot of my table relationships:
 
Any ideas what's wrong?
 
 

8 Replies

  • DataZoe's avatar
    DataZoe
    Microsoft Employee

    I ran into a similar issue. Is your Date Dim a calculated table in Power BI that is getting the start/end dates from another table?

  • StephenK , you to remove bi-directional join as that is causing date in date dimension also getting filtered.

    Make it only one-directional 1- Many from date to Data table

  • v-deddai1-msft's avatar
    v-deddai1-msft
    Community Support

    Hi StephenK ,

     

    In addition to amitchandak's reply, you should  make it only one-directional 1- Many from date to Data table. Because bi-directional join as that may cause date in date dimension also getting filtered. if you are trying to use these time intelligence functions like SAMEPERIODLASTYEAR or DATEADD, It needs a contiguous interval in date column.

     

    If there is a filter to remove rows from the middle.   Same period last year wants to look at just exactly 1 "period" -- that can be a week, day, month, 4.6 weeks... but they need to be 1 continuous range not like "the 1st and 4th week of July" (which would have a gap... in the 2nd and 3rd weeks, and is not allowed).

     

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

     

    Best Regards,

    Dedmon Dai