Forum Discussion
Need help with a formula: difference compared to previous quarter when quarters are custom.
I would like to calculate the difference in the number on leads this quarter versus the numbers of leads on the past quarter.
So for instance if last quarter I had 10 leads and this quarter 12 the difference will be 2.
Then I want to use this to see a trend (line chart) over time for the last X quarters.
The issue I have is our quarters are custom and so I can't use a date table, we are numbering our quarters starting from 1 when we started and each quarter gets a new number. The quarter number is unique and there will never be duplicates.
So for instance now I am in quarter 92 and last quarter was quarter 91. I think I need to somehow use this for the calculation?
I am struggling to find how to build the calculation. Any help with this will be really appreciated.
Thanks so much in avance
- Anonymous2 years ago
Hi AurelieP ,
You can try measure formula like below:
Result = VAR cur = MAX ( YourTable[Quarter number] ) VAR cur_leads = CALCULATE ( SUM ( 'YourTable'[# Leads] ), FILTER ( ALL ( YourTable ), 'YourTable'[Quarter number] = cur - 1 ) ) VAR difference = MAX ( YourTable[# Leads] ) - cur_leads RETURN IF ( cur - 1 <> 0, DIVIDE ( difference, cur_leads ), BLANK () )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly
3 Replies
- vanessafvg
Community Champion
in order to give you the best possible solution, please provide some sample data with an example of what you are expecting to see and how?
- AureliePFrequent Visitor
Hello ,
Here is an example, I want to calculate the difference and the variation
The difference is number of leads in a specific quarter - number of leads 1 quarter before.
The variation is ((leads in a specific quarter − leads 1 quarter before) / leads 1 quarter before)×100
I also put the formulas in the 1st 2 rows above.
I know these 2 fields need to be measures and to calculate it I probably need to use the quarter number as a reference and -1 for the previous quarter.. Hope this helps
Quarter number # Leads Difference Variation 1 15 2 25 25-15= 10 ((25-15)/15)*100=
67%
3 150 150-25= 125 ((150-25)/55)*100=
500%
4 75 -75 -50% 5 12 -63 -84% 6 15 3 25% 7 20 5 33% 8 30 10 50% 9 10 -20 -67% 10 50 40 400% 11 25 -25 -50% 12 15 -10 -40% 13 30 15 100% 14 60 30 100% 15 14 -46 -77% 16 35 21 150% 17 20 -15 -43% 18 18 -2 -10% 19 100 82 456% - AnonymousNot applicable
Hi AurelieP ,
You can try measure formula like below:
Result = VAR cur = MAX ( YourTable[Quarter number] ) VAR cur_leads = CALCULATE ( SUM ( 'YourTable'[# Leads] ), FILTER ( ALL ( YourTable ), 'YourTable'[Quarter number] = cur - 1 ) ) VAR difference = MAX ( YourTable[# Leads] ) - cur_leads RETURN IF ( cur - 1 <> 0, DIVIDE ( difference, cur_leads ), BLANK () )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly