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.
Related
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)
I have the below Excel-table:
| A | B
---------|-----------|---------------
1 | 500 |
2 | 500 |
3 | 500 |
---------|-----------|----------------
4 | 600 |
5 | 600 |
---------------------|----------------
6 | 300 |
---------------------|----------------
7 | 800 |
8 | 800 |
9 | 800 |
---------------------|----------------
10 | 200 |
11 | 200 |
---------------------|----------------
12 | 900 |
---------------------|----------------
13 | 100 |
14 | 100 |
In Column A there a different numbers which can appear multiple times within the rows.
Now I am looking for a conditional formatting that identifies if a number has switched compared to the previous row and if so all the other rows with the same number are coloured in yellow until it switches again.
The result should look like this:
Do you have any idea what kind of conditional formatting I need to achive this?
Select column A
Insert new conditional formatting rule based on formula and use:
If one has Excel O365:
=ISEVEN(COUNT(UNIQUE(A$1:A1)))
Older versions of Excel could use:
=ISEVEN(SUMPRODUCT(1/COUNTIF(A$1:A1,A$1:A1)))
I would like to use a formula in Sheet B to obtain the following transformation.
I want to vlookup stack, over, flow, super, user and the associated id's and put them into the Sheet B format. The formula would be copied horizontally across many 'Names' and then down.
Current, sheet A:
+-------------+-------+-------+
| Position_ID | Name | Value |
+-------------+-------+-------+
| 5963650267 | stack | 10 |
| 5963650267 | over | 20 |
| 5963650267 | flow | 30 |
| 5963650267 | super | 40 |
| 5963650267 | user | 50 |
| 5963650268 | stack | 90 |
| 5963650268 | over | 110 |
| 5963650268 | flow | 80 |
| 5963650268 | super | 70 |
| 5963650268 | user | 20 |
+-------------+-------+-------+
Expected, Sheet B, headers and positions ids are already pre populated:
+-------------+-------+------+------+-------+------+
| Position_ID | stack | over | flow | super | user |
+-------------+-------+------+------+-------+------+
| 5963650267 | 10 | 20 | 30 | 40 | 50 |
| 5963650268 | 90 | 110 | 80 | 70 | 20 |
+-------------+-------+------+------+-------+------+
Assuming the data in Sheet A is located at A1:C11 (adjust as required), enter this Formula Array in Sheet B at B2 then copy to all required cells (i.e. C2:F2 and B3:F3)
=INDEX('Sheet A'!$C$1:$C$11,
MATCH(CONCATENATE($A2,"|",B$1),
CONCATENATE('Sheet A'!$A$1:$A$11,"|",'Sheet A'!$B$1:$B$11),0))
Formula Array must be entered by holding down CTRL + SHIFT + ENTER
Apologies for the formatting - but if you add the vlookups to the empty shell of position_ids by name on sheet b it should give you the grid you're looking for.
Sheeta! ID&Name Position_ID Name Value
=C2&D2 1 stack 10
=C3&D3 1 over 20
=C4&D4 1 flow 30
=C5&D5 1 super 40
=C6&D6 1 user 50
=C7&D7 2 stack 90
=C8&D8 2 over 110
=C9&D9 2 flow 80
=C10&D10 2 super 70
=C11&D11 2 user 20
Sheetb! stack over flow super user
1 =VLOOKUP($A14&B$13,$B$2:$E$11,4,FALSE) =VLOOKUP($A14&C$13,$B$2:$E$11,4,FALSE) =VLOOKUP($A14&D$13,$B$2:$E$11,4,FALSE) =VLOOKUP($A14&E$13,$B$2:$E$11,4,FALSE) =VLOOKUP($A14&F$13,$B$2:$E$11,4,FALSE)
2 =VLOOKUP($A15&B$13,$B$2:$E$11,4,FALSE) =VLOOKUP($A15&C$13,$B$2:$E$11,4,FALSE) =VLOOKUP($A15&D$13,$B$2:$E$11,4,FALSE) =VLOOKUP($A15&E$13,$B$2:$E$11,4,FALSE) =VLOOKUP($A15&F$13,$B$2:$E$11,4,FALSE)
Sheetb! stack over flow super user
1 10 20 30 40 50
2 90 110 80 70 20
Let's say I have the following table:
CORP | COAST | CITY | DONE | MISSING | TOTAL
-------------------------------------
New | West | LAX | 2 | 4 | 6
Old | West | SFO | 3 | 3 | 6
New | East | NYC | 4 | 2 | 6
I make a pivot table that looks like this:
CORP:
COAST: NEW | OLD
-------------------------------------
EAST |
SUM OF TOTAL | 6 |
SUM OF DONE | 4 |
SUM OF MISSING | 2 |
WEST
SUM OF TOTAL | 6 | 6
SUM OF DONE | 2 | 3
SUM OF MISSING | 4 | 3
I want to now add a ROW that is the percentage DONE of the TOTAL amount. I.e. something like this:
CORP:
COAST: NEW | OLD
-------------------------------------
EAST |
SUM OF TOTAL | 6 |
SUM OF DONE | 4 |
SUM OF MISSING | 2 |
% DONE | %67|
WEST
SUM OF TOTAL | 6 | 6
SUM OF DONE | 2 | 3
SUM OF MISSING | 4 | 3
% DONE | %33| %50
The formula for % DONE is DONE / TOTAL
I've tried adding another DONE field to the pivot table (i.e. SUM OF DONE2) then setting the value to be % OF, the base field TOTAL and the base value (previous) however that makes % DONE return the value of #N/A. I've tried various combinations of the above however all are returning the same #N/A. I.e. my pivot table is looking like this:
CORP:
COAST: NEW | OLD
-------------------------------------
EAST |
SUM OF TOTAL | 6 |
SUM OF DONE | 4 |
SUM OF MISSING | 2 |
% DONE |#N/A|
WEST
SUM OF TOTAL | 6 | 6
SUM OF DONE | 2 | 3
SUM OF MISSING | 4 | 3
% DONE |#N/A| #N/A
I've tried Googling how to do it but still to no avail. Please let me know if what I am looking for is possible.
On the Analyze tab, add a Calculated field with the formula
= 'DONE'/'TOTAL'
There is an option in Pivot Table Options that allows you to show blank if there is an error, so you don't get an N/A for old/east. You can go into field settings and format the field as a percentage.
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.