Forum Discussion
Previous weekly sales
Hi there,
I need a column with the previous weeks sales. The current week measure is working well but the previous week is not working. What am I doing wrong?!?
Hi Lynzmaz
You can try this, create the measures below. For more please see sample file attached below
ThisWeek = CALCULATE(SUM('2019'[Net Sales]),FILTER(ALL('2019'),RELATED('Calendar'[WeekRank])= MAX('Calendar'[WeekRank])))LastWeek = CALCULATE(SUM('2019'[Net Sales]),FILTER(ALL('2019'),RELATED('Calendar'[WeekRank])= MAX('Calendar'[WeekRank])-1))result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandak
Super User
Lynzmaz , Create a week rank in your date table and try measure like the example
new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW formatmeasures
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8 - v-xiaotang
Community Support
Hi Lynzmaz
You can try this, create the measures below. For more please see sample file attached below
ThisWeek = CALCULATE(SUM('2019'[Net Sales]),FILTER(ALL('2019'),RELATED('Calendar'[WeekRank])= MAX('Calendar'[WeekRank])))LastWeek = CALCULATE(SUM('2019'[Net Sales]),FILTER(ALL('2019'),RELATED('Calendar'[WeekRank])= MAX('Calendar'[WeekRank])-1))result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.