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
Then how to calculate Current week sales? Is That change dynamically for upcoming weeks?
- amitchandak6 years agoSuper User
Check if this can help
This week sales = var _date = date(year(today()),month(today()),day(today())) var _Week_ED = _date + (-1*WEEKDAY(_date)+1) var _Week_SD= _date +(7-1*WEEKDAY(_date)) Return CALCULATE(sum(Sales[Sales Amount]),all('Date'),Sales[Sales Date]>=_Week_SD && Sales[Sales Date]<=_Week_ED) Last week sales = var _date = date(year(today()),month(today()),day(today())) var _Week_ED = _date +( (-1*WEEKDAY(_date)+1)-7) var _Week_SD= _date +((7-1*WEEKDAY(_date))-7) Return CALCULATE(sum(Sales[Sales Amount]),all('Date'),Sales[Sales Date]>=_Week_SD && Sales[Sales Date]<=_Week_ED)