I want to count how many years a company has increased the profit from now and in a continuing streak.
In the picture it has to count until 2014 because the profits have not been increased relative to 2013. For steady profits, it has to count until 2012 because in 2011 the profits were higher than after that. So these are the two calculations that should be done. Import is that it shouldn't count rows of years where the profits were 0 - 0 - 0 - 0 (=steady, but 0 is no profit at all).
So it's like quality criteria to see how well a company is doing at its business. So if there is one interruption then everything before is irrelevant.
And the formulas should change dynamically, so if there will be data for 2018, 2019 ... then it should automatically count from the newest data. (there will be space between the formula column and the column for the latest year for more years)
Explanation for this new question: I needed a more flexible and complex solution for my problem and wanted to differentiate that in this question. So this may help others with similar problems.
To calculate
Years of Increases
enter the following formula inCell L2
and to calculate
Years of Steady Profits
enter below formula inCell M2
Both the above formulas are array formula so commit by pressing Ctrl+Shift+Enter. Drag/Copy down as required. See image for reference.
In case you want this formula to be dynamic i.e. after adding new column for another year you want formula to work correctly then consider the following.
In
Column K
enter some dummy character sayx
and then enter the following formula inCell L2
and in
Cell M2
Both formulas are array formula. Drag/Copy down as required. See image for reference.
Now when you select
Column K
and insert new column, formulas will change accordingly.Notice formula (formula bar) in the image below.
EDIT : Avoid counting streak of zeros
0-0-0-0
For
Years of Steady Profits
use following formula inCell M2
This is an array formula.
VBA Solution :
See image for reference.
Unless you want to write a custom function (VBA), the simplest way to achieve this is to have a corresponding table to the profit table that tracks a companies profit streak. This corresponding table indicates years in which there is a profit streak by returning a 1 if:
You then sum the logical values