Forum Discussion
Week on week differences based on specfic field account number
Hi All,
I have been reading a few posts that are similar but don't quite seem to be the same problem so hoping you can help 🙂
My sample data has multiple rows that show the Account Number with the weekly end period date and the period balance at that point. Each week a new record is created for each account.
I would like to show the difference week on week but unique to the account number. i.e. Account Number 100 shows 14 weekly balances so far in this financial year. So I need to see the difference from 05-Apr-20 to 12-Apr-20 WHERE AccountID=100 and so on.
Any help would be much appreciated.
| Account ID | Period End Date | Period Balance |
| 100 | 05-Apr-20 | -£14.83 |
| 100 | 12-Apr-20 | -£37.41 |
| 100 | 19-Apr-20 | -£25.81 |
| 100 | 26-Apr-20 | -£25.81 |
| 100 | 03-May-20 | -£14.14 |
| 100 | 10-May-20 | -£49.15 |
| 100 | 17-May-20 | -£37.48 |
| 100 | 24-May-20 | -£25.81 |
| 100 | 31-May-20 | -£14.14 |
| 100 | 07-Jun-20 | -£49.15 |
| 100 | 14-Jun-20 | -£37.47 |
| 100 | 21-Jun-20 | -£25.81 |
| 100 | 28-Jun-20 | -£14.14 |
| 100 | 05-Jul-20 | -£49.15 |
| 220 | 05-Apr-20 | -£344.20 |
| 220 | 12-Apr-20 | -£262.05 |
| 220 | 19-Apr-20 | -£179.90 |
| 220 | 26-Apr-20 | -£97.76 |
| 220 | 03-May-20 | -£15.60 |
| 220 | 10-May-20 | -£289.43 |
| 220 | 17-May-20 | -£207.50 |
| 220 | 24-May-20 | -£125.13 |
| 220 | 31-May-20 | -£42.98 |
| 220 | 07-Jun-20 | -£316.81 |
| 220 | 14-Jun-20 | -£234.66 |
| 220 | 21-Jun-20 | -£152.51 |
| 220 | 28-Jun-20 | -£70.36 |
| 220 | 05-Jul-20 | -£344.19 |
| 330 | 05-Apr-20 | -£0.34 |
| 330 | 12-Apr-20 | £74.72 |
| 330 | 19-Apr-20 | -£175.48 |
| 330 | 26-Apr-20 | -£100.49 |
| 330 | 03-May-20 | -£25.36 |
| 330 | 10-May-20 | £49.70 |
| 330 | 17-May-20 | £124.70 |
| 330 | 24-May-20 | -£125.41 |
| 330 | 31-May-20 | -£50.38 |
| 330 | 07-Jun-20 | £24.68 |
| 330 | 14-Jun-20 | £99.74 |
| 330 | 21-Jun-20 | -£150.47 |
| 330 | 28-Jun-20 | -£75.40 |
| 330 | 05-Jul-20 | -£0.34 |
JPScotland it should be easy, check this video.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
Hi JPScotland ,
If you want a measure, you can refer Parry and amitchandak’s answer.
If you want a calculate column, we can use the following formula to meet your requirement.
difference Column = VAR _lastweek = CALCULATE ( SUM ( 'Table'[Period Balance] ), FILTER ( 'Table', 'Table'[Period End Date] = EARLIER ( 'Table'[Period End Date] ) - 7 && 'Table'[Account ID] = EARLIER ( 'Table'[Account ID] ) ) ) RETURN IF ( ISBLANK ( _lastweek ), BLANK (), 'Table'[Period Balance] - _lastweek )If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
4 Replies
- parry2k
Super User
JPScotland it should be easy, check this video.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- amitchandak
Super User
JPScotland , refer if my blog on week can help
- v-zhenbw-msft
Community Support
Hi JPScotland ,
If you want a measure, you can refer Parry and amitchandak’s answer.
If you want a calculate column, we can use the following formula to meet your requirement.
difference Column = VAR _lastweek = CALCULATE ( SUM ( 'Table'[Period Balance] ), FILTER ( 'Table', 'Table'[Period End Date] = EARLIER ( 'Table'[Period End Date] ) - 7 && 'Table'[Account ID] = EARLIER ( 'Table'[Account ID] ) ) ) RETURN IF ( ISBLANK ( _lastweek ), BLANK (), 'Table'[Period Balance] - _lastweek )If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
- JPScotland
Helper I
Thank you all for replying. I actually looked at everyones comments and I think you all answered it. It also taught me a few new things which is great.
I went with v-zhenbw-msft answer as I am still new to PowerBI and the code was just ready to lift straight into the report.
Thanks again all.
JP