Forum Discussion
How to calculate dynamically Changing week
If you have a date table and week slicer coming from that you can have 7 days behind measure to give you last week
last week Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-7,Day)))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
Isnt that formula just gonna give him - 7 days so it can be between weeks depending on what day it is today?
I mean week 52 is 52 not half 51 & half 52
/Adam
- amitchandak6 years agoSuper User
Try like
This WEEK var _max_week = maxx(date,date[Fiscal Week]) return calculate(sum(x),all(date[Fiscal Week]), Date[Fiscal Week] =_max_week) last week var _last_week = calculate(Max(Fiscal Week),datediff(date[date],-7,day))// return calculate(sum(x),all(date[Fiscal Week]), Date[Fiscal Week] =_last_week)I