March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
I am trying to calculate revenue churn which is defied as revenue decrease year over year at client level. I have a measure
Churn = if(([Revenue]-[Rev_PY])<0,[Revenue]-[Rev_PY],0)
The result works at the client level but not at total level - you can see that the total churn $ is calculated as total revenue of 2015.16 - prior year, which is not what I wanted.
What is the right formula to get it right at both customer and all up levels?
Thanks,
Hui
Solved! Go to Solution.
Hey, no worries. I don't know of a way to make the same measure work for both use cases; maybe it's possible but certainly not trivial. Here's an adapted formula (I'd imagine it will be a fair amount slower though) to use when you're looking at the regional level:
Churn = SUMX(SUMMARIZE('Table', 'Table'[Cust], 'Table'[Plan Year], "Revenue1", SUM([Revenue]), "Rev_PY1", SUM([Rev_PY])), if(([Revenue1]-[Rev_PY1])<0,[Revenue1]-[Rev_PY1],0))
Not testing so there may be minor issues, and I may have grouped by the wrong columns for your purposes, but in general the SUMMARIZE function is definitely your friend here - it will allow you to specify the level of aggregation before doing the calculation.
You need this calculation to occur at the row level, not the aggregated level. Currently, it's just doing the aggregated calculation. Try wrapping in a SUMX as an easy solution:
Churn = SUMX('Table', if(([Revenue]-[Rev_PY])<0,[Revenue]-[Rev_PY],0))
Thank you very much jahida! The formula works but it is quite slow as I have 3m lines in my table. Any way to make it faster?
I'm not great with PowerBI efficiency, I've heard the Calculate function is implemented quite efficiently though, so you could try something like:
CALCULATE(SUM('Table'[Revenue]), [Revenue]-[Rev_PY]<0) - CALCULATE(SUM('Table'[Revenue]), [Revenue]-[Rev_PY]<0)
Obviously the above could be compressed using a similar SUMX as above but I would guess that SUM is implemented much more efficiently. Not having a 3m row dataset to test on, I can't conclusively say what would be fast though.
I took another look at the calculation with the sumx formula and have a question -
I have another table for region/market.With the SUMX formula the Churn is calculated at the lowest hierachy level. So if I look at the region level for a particular client, the churn does not necessarily equal to the regional revenue decline over year.
For example, if you look at customer MMM for region NA, the Churn number looks off as it is based on calculation on team level.
Plan Year | Cust | Region | Revenue | Rev_PY | YoY | Churn |
2015.16 | MMM | NA | 141,892 | 228,235 | (86,343) | (207,556) |
Plan Year | Cust | Region | Org Structure | Revenue | Rev_PY | YoY | Churn |
2015.16 | MMM | NA | Team1 | 1,444 | 1,444 | - | |
2015.16 | MMM | NA | Team2 | 219 | 219 | - | |
2015.16 | MMM | NA | Team3 | 188 | 188 | - | |
2015.16 | MMM | NA | Team4 | 133,639 | 155,998 | (22,359) | (195,614) |
2015.16 | MMM | NA | Team5 | (75) | 75 | ||
2015.16 | MMM | NA | Team6 | 3,201 | 17,968 | (14,767) | (5,971) |
2015.16 | MMM | NA | Team7 | 10,722 | (10,722) | ||
2015.16 | MMM | NA | Team8 | - | - | ||
2015.16 | MMM | NA | Team9 | - | - | ||
2015.16 | MMM | NA | Team10 | 82 | (82) | ||
2015.16 | MMM | NA | Team11 | 7,384 | (7,384) | ||
Total | 138,691 | 192,079 | (53,388) | (201,585) |
Is there a way to calculate this at the hierachy level as the one indicated in the chart/visualization?
Thanks,
Hui
Sorry for the confusion. Below 2 charts are the current results.
1. At team level
Plan Year | Cust | Org Structure | Revenue | Rev_PY | YoY | Churn |
2015.16 | MMM | Team1 | 1,444 | 1,444 | - | |
2015.16 | MMM | Team2 | 219 | 219 | - | |
2015.16 | MMM | Team3 | 188 | 188 | - | |
2015.16 | MMM | Team4 | 133,639 | 155,998 | (22,359) | (195,614) |
2015.16 | MMM | Team5 | (75) | 75 | ||
2015.16 | MMM | Team6 | 3,201 | 17,968 | (14,767) | (5,971) |
Total | 138,691 | 173,891 | (35,200) | (201,585) |
2. at region level
Plan Year | Cust | Revenue | Rev_PY | YoY | Churn |
2015.16 | MMM | 138,691 | 173,891 | (35,200) | (201,585) |
The team level is good. I would like to have the regional level looks like -
Plan Year | Cust | Revenue | Rev_PY | YoY | Churn |
2015.16 | MMM | 138,691 | 173,891 | (35,200) | (35,200) |
Thanks,
Hui
Hey, no worries. I don't know of a way to make the same measure work for both use cases; maybe it's possible but certainly not trivial. Here's an adapted formula (I'd imagine it will be a fair amount slower though) to use when you're looking at the regional level:
Churn = SUMX(SUMMARIZE('Table', 'Table'[Cust], 'Table'[Plan Year], "Revenue1", SUM([Revenue]), "Rev_PY1", SUM([Rev_PY])), if(([Revenue1]-[Rev_PY1])<0,[Revenue1]-[Rev_PY1],0))
Not testing so there may be minor issues, and I may have grouped by the wrong columns for your purposes, but in general the SUMMARIZE function is definitely your friend here - it will allow you to specify the level of aggregation before doing the calculation.
Thank you jahida. This is very helpful!
To clarify, are the numbers there current result or expected/desired result? And can I get the other one as well to understand the problem better?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
84 | |
66 | |
54 | |
43 |
User | Count |
---|---|
203 | |
106 | |
98 | |
65 | |
56 |