Forum Discussion
Anonymous
3 years agoNot applicable
this week versus last week difference
I have a table below in which i wanted to calculate or get the difference from this week's count against last week. below is a sample table output that i wanted to achieve. i wanted to get a dax formula for the Week Difference. Thank you in advance.
| CountOfECMs | WEEKENDINGSAT | Week Difference |
| 21 | 12/2/2017 | |
| 30 | 12/9/2017 | 9 |
| 33 | 12/16/2017 | 3 |
| 11 | 12/23/2017 | -22 |
| 8 | 12/30/2017 | -3 |
| 11 | 1/6/2018 | 3 |
| 25 | 1/13/2018 | 14 |
| 32 | 1/20/2018 | 7 |
| 16 | 1/27/2018 | -16 |
| 17 | 2/3/2018 | 1 |
| 25 | 2/10/2018 | 8 |
| 20 | 2/17/2018 | -5 |
| 22 | 2/24/2018 | 2 |
| 19 | 3/3/2018 | -3 |
| 17 | 3/10/2018 | -2 |
Hi, Anonymous
Please try formula like:
Week Difference = VAR last_week = CALCULATE ( MAX ( 'Table'[WEEKENDINGSAT] ), FILTER ( ALL ( 'Table' ), 'Table'[WEEKENDINGSAT] < MAX ( 'Table'[WEEKENDINGSAT] ) ) ) VAR _count_of_lastweek = CALCULATE ( [CountOfECMs1], FILTER ( ALL ( 'Table' ), 'Table'[WEEKENDINGSAT] = last_week ) ) RETURN IF ( ISBLANK ( _count_of_lastweek ), BLANK (), [CountOfECMs1] - _count_of_lastweek )Best Regards,
Community Support Team _ Eason
2 Replies
- Greg_DecklerCommunity Champion
Anonymous Easiest way would be to use a Sequential column: Sequential - Microsoft Power BI Community
- v-easonf-msftCommunity Support
Hi, Anonymous
Please try formula like:
Week Difference = VAR last_week = CALCULATE ( MAX ( 'Table'[WEEKENDINGSAT] ), FILTER ( ALL ( 'Table' ), 'Table'[WEEKENDINGSAT] < MAX ( 'Table'[WEEKENDINGSAT] ) ) ) VAR _count_of_lastweek = CALCULATE ( [CountOfECMs1], FILTER ( ALL ( 'Table' ), 'Table'[WEEKENDINGSAT] = last_week ) ) RETURN IF ( ISBLANK ( _count_of_lastweek ), BLANK (), [CountOfECMs1] - _count_of_lastweek )Best Regards,
Community Support Team _ Eason