I am trying to count the number of rows (in this case days) until the sum of positive values >= the original negative value or more conceptually an initial investment is fully paid-off. In the below example:
For the -70 (1/1/2021) the value would be 8 (1/1/2021 - 1/8/2021) inclusive.
For the next -70 (1/2/2021) the value would be 9 (1/2/2021 - 1/10/2021) inclusive.
For the next -30 (1/6/2021) the value would be 6 (1/2/2021 - 1/11/2021) inclusive.
I have found the following array formula that works for me:
=MATCH(D2,SUBTOTAL(9,OFFSET(B2,,,ROW(B2:B17)-ROW(B2))),1)
However, this does not pass over the other negative values in the column.
Requirement not to use helper columns if possible
Example of what I am trying to achieve:
+-----------+--------+----------------+
| Date | Amount | Desired Result |
+-----------+--------+----------------+
| 1/1/2021 | -70 | 8 |
+-----------+--------+----------------+
| 1/2/2021 | -70 | 9 |
+-----------+--------+----------------+
| 1/3/2021 | 0 | 0 |
+-----------+--------+----------------+
| 1/4/2021 | 0 | 0 |
+-----------+--------+----------------+
| 1/5/2021 | 0 | 0 |
+-----------+--------+----------------+
| 1/6/2021 | -30 | 6 |
+-----------+--------+----------------+
| 1/7/2021 | 40 | 0 |
+-----------+--------+----------------+
| 1/8/2021 | 30 | 0 |
+-----------+--------+----------------+
| 1/9/2021 | 0 | 0 |
+-----------+--------+----------------+
| 1/10/2021 | 70 | 0 |
+-----------+--------+----------------+
| 1/11/2021 | 30 | 0 |
+-----------+--------+----------------+
Any help would be appreciated -
Well I've come up with a formula that agrees with your figures. It may be more complicated than it needs to be because although your test data always works out so that the exact amount is paid off (exact match), I've added the case where an excess amount is paid (inexact match).
The principle is to develop a triangular matrix which uses mmult to select just one row of data, then two rows etc.
=IF(B2<0,IFERROR(MATCH(-SUMIF(B2:B$2,"<0"),MMULT(N(ROW(A$2:A$12)>=TRANSPOSE(ROW(A$2:A$12))),IF(B$2:B$12>0,B$2:B$12,0)),0),
MATCH(-SUMIF(B2:B$2,"<0"),MMULT(N(ROW(A$2:A$12)>=TRANSPOSE(ROW(A$2:A$12))),IF(B$2:B$12>0,B$2:B$12,0)),1)+1)-ROW()+2,0)
Related
I am trying to lookup data that is the first occurrence of an ID looking upwards in excel. I would like to stop looking upwards when the cell value is ID is 0.
I have used the following to find the first occurrence when looking upwards:
In Cell D8:
=LOOKUP(2,1/($A$2:A8=C8),$B$2:B8)
In Cell D9:
=LOOKUP(2,1/($A$2:A9=C9),$B$2:B9)
For the case of desired outcome = 13 this works, however when there are consecutive IDs I would like to return the top most non-zero data field. Example desired outcome = 15 with the current formula returns 0.
How can I continue looking upwards until the top most ID = 2 before ID =0?
+----+------+--------------+-----------------+
| ID | Data | Lookup Value | Desired Outcome |
+----+------+--------------+-----------------+
| 2 | 18 | 1 | No Formula |
+----+------+--------------+-----------------+
| 1 | 25 | 2 | No Formula |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 1 | 13 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 15 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 0 | 1 | 13 |
+----+------+--------------+-----------------+
| 1 | 0 | 2 | 15 |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
Put this in D4 and copy down:
=IFERROR(LOOKUP(2,1/(($A$2:A4=C4)*($B$2:B4<>0)),$B$2:B4),0)
Put this in D4 and copy down:
=IFNA(LOOKUP(9^9,1/B$2:B4^-1/($A$2:A4=C4)),)
| A B C D | E F | G H
----|----------------------------------------------------|-----------------------|-------------------
1 | | |
2 | Products date quantity | |
----|----------------------------------------------------|-----------------------|-------------------
3 | Product_A 2020-01-08 0 | From 2020-01-01 | Result: 800
4 | Product_A 2020-12-15 0 | to 2020-10-31 |
5 | Product_A 2020-12-23 0 | |
6 | Product_A 500 | |
----|----------------------------------------------------|-----------------------|------------------
7 | Product_B 2020-11-09 0 | |
8 | Product_B 2021-03-14 0 | |
9 | Product_B 700 | |
----|----------------------------------------------------|-----------------------|------------------
10 | Product_C 2020-02-05 0 | |
11 | Product_C 2020-07-19 0 | |
12 | Product_C 2020-09-18 0 | |
13 | Product_C 2020-09-25 0 | |
14 | Product_C 300 | |
14 | | |
15 | | |
In the table I have listed different products with multiple dates per product.
Below each product there is a row in which a quantity is displayed.
Now in Cell H3 I want to get the Sum of the quantity of all products that have at least one date between the dates in Cell F3 and Cell F4. In the example this applies to Product_A and Product_C therefore the sum is 500+300=800.
I have no clue what kind of formula I need to achieve this.
I guess it must be something like this:
SUMIFS(Date in Cell F3 OR in Cell F4 exists for Product in Column C THEN SUM over Column D)
Do you have an idea how this formula has to look like?
One way would be with SUMPRODUCT() combined with COUNTIFS():
=SUMPRODUCT((COUNTIFS(B3:B14,B3:B14,C3:C14,">="&F3,C3:C14,"<="&F4)>0)*D3:D14)
I have this data below in Excel. What I want is to return the No.of Inactive months and the Inactive months themselves.
ACTIVITY MONTH
Jan17 Feb17 Mar17 Apr17 Reg Month No.Inactive months Months Inactive
User ID
1 5 38 0 60 Jan17
2 0 242 203 20 Feb17
3 30 0 0 30 Jan17
4 0 0 0 40 Apr17
5 0 0 16 0 Mar17
To count the inactive months you can use the following.
+---+------+--------+--------+--------+--------+--+-----------------+
| | A | B | C | D | E | F| G |
+---+------+--------+--------+--------+--------+--+-----------------+
| 1 | User | Jan 17 | feb-17 | mar-17 | apr-17 | | Inactive months |
| 2 | 1 | 5 | 38 | 0 | 60 | | 1 |
| 3 | 2 | 0 | 242 | 203 | 20 | | 1 |
| 4 | 3 | 30 | 0 | 0 | 30 | | 2 |
| 5 | 4 | 0 | 0 | 0 | 40 | | 3 |
| 6 | 5 | 0 | 0 | 16 | 0 | | 3 |
+---+------+--------+--------+--------+--------+--+-----------------+
where in cell G2 the is this formula =COUNTIF(B2:E2,0)
To show the list of inactive months it's a little bit harder.
The point is that you have to explain how you want to see these results.
The easier way is to use the conditional formatting anc color the cell with zero (but this is not so useful). Others way could be to traspose the table and filter the column with zero. Another one could be to use a VBA macro....
I'm trying to write a formula to find the nearest cell that meets a certain criteria in short i have a table of data for an antenna that denotes its performance at various angles around it, and I want to calculate the 3dB beamwidth.
the table is in the form:
+-------------------------------------+
| Angle | Freq 1 | Freq 2 | Freq 3 |
+----------+--------+--------+--------+
| 0 | -2 | -4 | -6 |
| 10 | -2.5 | 4 | -7 |
| 20 | -2 | 5 | 0 |
| 30 | 1 | 6 | 2 |
| 40 | 4 | 7 | 2 |
| 50 | 5 | 6 | 3 |
| 60 | 4 | 6 | 2 |
| 70 | 2 | 5 | 2 |
| 80 | 0 | 4 | 2 |
| 90 | -2.5 | 2 | 1 |
| 100 | -2 | -4 | 0 |
| ... | ... | ... | ... |
| 350 | -2 | -4 | -6 |
| 360 | -2 | -4 | -6 |
+----------+--------+--------+--------+
| Max | 5 | 7 | 3 |
| Ang. Max | 50 | 40 | 50 |
+----------+--------+--------+--------+
so i currently use max to get the highest value in the table, and INDEX([angle range],MATCH([max cell],[freq column range],0)) to look up the corresponding angle of that maximum value.
I need a formula that will find the corresponding angle for the last cell above the maximum that is withing 3dB of the max and the angle for the last cell below it, then get the difference between those angles to get the beamwidth in degrees, so for Freq 1:
above: 4 - angle 40
below: 2 - angle 70
beamwidth: 70 - 40 = 30
freq 2:
above: 4 - angle 10
below: 4 - angle 80
beamwidth: 80 - 10 = 70
freq 3:
above: 0 - angle 20
below: 0 - angle 100
beamwidth: 100 - 20 = 80
ideally it would work linearly interpolate between the last cell that is withing 3dB and the first outside to guess the angle when between these steps... but that might be a bridge too far.
I want to avoid doing this with a macro because I want it to be calculated automatically any time the source data changes, and i need to be able to send this around to machines that are not allowed to run macros.
I thought about using LOOKUP of VLOOKUP but these need to match an exact value unless an option is set, but when i tried with that option set I got no matches at all for the value of (max - 3)
not really sure what else to try.
For Excel 2010 and above:
To find the Above:
=INDEX($A:$A,AGGREGATE(15,6,ROW(B$2:B$12)/(B$2:B$12>=MAX(B$2:B$12)-3),1))
To find the Below, change the 15 to 14:
=INDEX($A:$A,AGGREGATE(14,6,ROW(B$2:B$12)/(B$2:B$12>=MAX(B$2:B$12)-3),1))
Then drag/copy across to reference the next columns.
For 2007 and below you will need to use the following array formulas:
For Above:
=INDEX($A:$A,SMALL(IF(B$2:B$12>=MAX(B$2:B$12)-3,ROW(B$2:B$12)),1))
For Below:
=INDEX($A:$A,LARGE(IF(B$2:B$12>=MAX(B$2:B$12)-3,ROW(B$2:B$12)),1))
Being Array formulas they need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
I have following problem:
I want to give scores to a range of numbers from 1-10 for example:
| | A | B |
|---|------|----|
| 1 | 1209 | 1 |
| 2 | 401 | 7 |
| 3 | 123 | 9 |
| 4 | 49 | 10 |
| 5 | 30 | 10 |
(Not sure if B is 100% correct but roughly)
I got the B values with
=ABS(CEILING(A1;MAX($A$1:$A$32)/10)*10/MAX($A$1:$A$32)-11)
It seems to work but if I for example take numbers like
| | A | B |
|---|------|----|
| 1 | 100 | 1 |
| 2 | 90 | 2 |
| 3 | 80 | 3 |
| 4 | 70 | 4 |
| 5 | 50 | 6 |
But I want 50 to be 10.
I would like to have it scalable so I can do it with a 1-10 or 1-100 or 5-27 or whatever scale and with however many numbers in the list and whatever numbers to score from.
Thanks!
Use this formula:
=$E$1 + ROUND((MIN($A:$A)-A1)/((MAX($A:$A)-MIN($A:$A))/($E$1-$E$2)),0)
It is scalable. You put the max and min in E1 and E2.