Forum Discussion
Sum all values per row until limit is reached with multiple criteria
Hi Anonymous,
a file with some example data would really be helpful
- Anonymous7 years agoNot applicable
sturlaws - Here is the example data for both power bi and excel from my screenshot. The simplest example of the scenario as already shown if you stay filtered on that account ID, Product Category, and Contract Number but I need this calculation to work without filtering the data.
Thanks so much for the help!
https://drive.google.com/open?id=1kPW5eAEieDxl5_rZydw0bB-2yW1936gi
https://drive.google.com/open?id=15bAu-qsKEmeGMNZSpHzFCNLVcg9lSkUc
- sturlaws7 years ago
Resident Rockstar
A bit tricky this.
How do you want to visualize the 12 month revenue? Is it just latest date pr contract, or do you want to track the development over time?
Or do you want to show it row by row like you have shown in you example?- Anonymous7 years agoNot applicable
To keep it somewhat simple let's just say we're looking for the last 12 months of revenue starting at the latest end date per Account ID and per Product category.
So, for this example, the top 2 lines are < 12 months so I'd add the revenue from those lines (49,667 & 193,151) to the next most recent product lines (bottom 3 lines with end dates of 8/24/19). However, for these bottom 3 lines, I'd just be looking for a proportion of that revenue that gets me to a total of 12 months. So the math would be (revenue / initial term) * (12 - 10.19) <--(i.e. this is the sum of the initial terms that have already been summed together. In this scenario there is only one contract with a term of 10.19) for each of the bottom three lines separately (math explained: dividing revenue by initial term gets the monthly revenue value and then the second subtraction portion is getting the number of months that are still remaining out of the 12-months total). I could then sum up each of the 5 lines to get the prior 12-month value total as of 6/29/2019.
Note: I'd need a DO UNTIL function because if the bottom 3 lines were very short, we'll say 1 month long, then I'd need to continue down the column adding in other rows until a 12 month total was reached or if there weren't any more rows to add in. (that being said, I'd also need to add in parameters for this calculation saying that is there is ever a gap period >= 6 months then do not add in that row's revenue into the calculation.
I know this sounds extremely confusing so please let me know what I can explain better.