Forum Discussion
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
- amitchandakSuper User
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))
- NarukkpHelper V
Hi amitchandak ,
Thanks for your reply, Even i am getting same below error if i am using dateadd funtion.- amitchandakSuper User
- NarukkpHelper V
Hi amitchandak , Yes we are using Bi Directional relationship. As part of data model we have to use BI- Directional relationship only. So could you please let me know how to achive this requiment when we are using BI-Directional relationship.
- amitchandakSuper User
Narukkp , when you do bi-directional with date table, it will filter date from fact. So keep date table join as single/one directional only
- v-zhangtiCommunity 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.
- NarukkpHelper 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