The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I need to calculate year-over-year percentage change on a weekly basis i.e. for last week.
I have a total sales custom measure which calculates the total sales of the organisation.
Please help me with how to do this.
Solved! Go to Solution.
With week based calculations there are a lot of details that you need to specify explicitly in order to get what you need, including what day is start of week, what should happen around new year, and how should weeks without data affect the user experience and what you see, if this scenario is relevant for your use case.
Here are two solutions for common scenarios. In all examples, 'Financials' is the fact table and 'Financials'[Sales] is the column containing the values.
1. Select one week and compare with the seven days that are one year ago. In this case, the selected week might be one calendar week, e.g. Monday to Sunday, but the same dates minus one year will not be one calendar week but e.g. Wednesday to Tuesday of the following week in the previous year.
Steps inclused:
2. Second approach compares the selected calendar week with the same calendar week number in the previous year. If the selected week is calendar week 53 and the previous year has only 52 weeks, then week 53 is compared against week 52 of the previous year (you can specify and implement different behavior as well, of course).
Steps included:
A sample solution can look like this. Be aware that in my sample data there isn't data for every day:
BR
Martin
Hi @priyam0003
Do you
want to compare one week with one week ago or compare one week with the week one year ago?
BR
I want to compare one week with the week one year ago.
With week based calculations there are a lot of details that you need to specify explicitly in order to get what you need, including what day is start of week, what should happen around new year, and how should weeks without data affect the user experience and what you see, if this scenario is relevant for your use case.
Here are two solutions for common scenarios. In all examples, 'Financials' is the fact table and 'Financials'[Sales] is the column containing the values.
1. Select one week and compare with the seven days that are one year ago. In this case, the selected week might be one calendar week, e.g. Monday to Sunday, but the same dates minus one year will not be one calendar week but e.g. Wednesday to Tuesday of the following week in the previous year.
Steps inclused:
2. Second approach compares the selected calendar week with the same calendar week number in the previous year. If the selected week is calendar week 53 and the previous year has only 52 weeks, then week 53 is compared against week 52 of the previous year (you can specify and implement different behavior as well, of course).
Steps included:
A sample solution can look like this. Be aware that in my sample data there isn't data for every day:
BR
Martin
User | Count |
---|---|
15 | |
12 | |
7 | |
6 | |
5 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |