Forum Discussion
Cumulative Comparison Between This Week and Last Week in a Single Visual
- Anonymous1 year ago
Hi,
Thanks for the solution amitchandak offered, and i want to offer some more information for user to refer to.
hello drx , based on your description, you can refer to the following sample.
Sample data
Calendar table.
There is a 1:n relationship between the tables.
Then for this week cumulative totals.
CE Orders = IF ( SUM ( 'T_Verkooporder'[Aantal ce besteld] ) <> BLANK (), CALCULATE ( SUM ( 'T_Verkooporder'[Aantal ce besteld] ), ALLSELECTED ( 'DM_Leverdatum' ), 'DM_Leverdatum'[Datum] <= MAX ( 'DM_Leverdatum'[Datum] ) ) )For last week.
CE Last week = CALCULATE([CE Orders],DATEADD('DM_Leverdatum'[Datum],-7,day))Then create a measure to control the last week start from Monday.
Flag = VAR a = MAXX ( ALLSELECTED ( 'DM_Leverdatum'[Datum] ), [Datum] ) VAR b = a - WEEKDAY ( a, 2 ) + 1 RETURN IF ( SELECTEDVALUE ( 'DM_Leverdatum'[Datum] ) >= b && SELECTEDVALUE ( 'DM_Leverdatum'[Datum] ) <= a, 1, 0 )Then put the following fields in visual.
Then put the falg measure to the visual filter.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
drx , Create a week rank column in Date/calendar table
Have these new columns in Date Table, Week Rank is Important in Date/Week Table
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
WeekDay = weekday([Date],2)
Have these new columns in Date Table, Week Rank is Important in Date/Week Table
Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format
And measures like
WTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank]) && 'Date'[WeekDay]<=max('Date'[WeekDay])))
LWTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1 && 'Date'[WeekDay]<=max('Date'[WeekDay]) ))
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
I'm using direct querry so i can't create collumns