Forum Discussion

Narukkp's avatar
Narukkp
Helper V
4 years ago

SAMEPERIODLASTYEAR function is not working for Week Day name columns

Hi Team,

Below SAMEPERIODLASTYEAR function is not working when i drag a week day name (Sun,Mon..) column in visualizations but it is working as expected when i drag the MonthYear Column, Day column.

 

I have identified that why it is giving error i.e if I selected week day names so we are not getting continuous dates, SAMEPERIODLASTYEAR function expect continuous dates. Please let me know any one workaround for my requirement.

 

My requirement – If I drag the week day name column, it should show the last year of week day name wise data.

 

LastYearSales=CALCULATE(SUM(Fact_Missed_Pickups[Missed_Pickups]), SAMEPERIODLASTYEAR(Dim_Date[Date]))

 

8 Replies

  • Narukkp , Make sure Dim_Date is marked as date table and you are using month, week , day from date table in visual

     try like

     

    LastYearSales=CALCULATE(SUM(Fact_Missed_Pickups[Missed_Pickups]), dateadd(Dim_Date[Date],-1, year))

     

     

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, Narukkp 

     

    Can you provide simple Excel data or PBIX files for testing? Please remove sensitive data in advance. What kind of results do you expect? Is it possible to show it with example images?

     

    Looking forward to your reply.

     

    Best Regards,

    Community Support Team _Charlotte

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

    • Narukkp's avatar
      Narukkp
      Helper V

      Hi ,

      v-zhangti it is working as expected if we have a single direction but it is not working when we have both direction relation ship.
      Actually my requirement is- I have one slicer and it contains the data like MonthYear,Week,Date,DayName. In Slicer if i select Month year then my X-axis should be shown the Month year, if i select Day Name from slicer value then my x-axis should be shown as DayName. 

      Is there any possiblity to select the dynamic caluculate columns based on slicer selction instead of Book marks and single direction relation ship