Excel - allocate weight based on text - excel

I have an risk control assessment where some controls are key and hold greater weight than non key controls.
Key vaule (1-4)
Y 4
Y 3
N 2
N 2
I want the keys with a "Y" to be summed at a weight of 70% and the non-keys with an "N" to be summed at a weight of 30%.
If we add the column we get 11. However, I want the 7 (4+3) to be multiplied by 70% and the 4 (2+2) be multiplied by 30%.
There may be 4 rows or 40. There generally are only 1 or 2 key controls ("Y"), but, if there are 40 rows or controls, there may be up to 5 "Y"s.
Any thoughts?

A simple way to do what I think you want would be to create a third column that had formulas like this one: =IF(A1="Y",B1*0.7,B1*0.3). Then, you could use the SUM function to add up all of the results. See the cells with formulas below.
Key Value Weighted Value
Y 1 =IF(A2="Y",B2*0.7,B2*0.3)
N 2 =IF(A3="Y",B3*0.7,B3*0.3)
N 3 =IF(A4="Y",B4*0.7,B4*0.3)
Y 4 =IF(A5="Y",B5*0.7,B5*0.3)
=SUM(C2:C5)
Here would be the result...
Key Value Weighted Value
Y 1 0.7
N 2 0.6
N 3 0.9
Y 4 2.8
5

As you can seen from #TimWilliams' comment, there is some uncertainty about your requirement but if it is weighting factors then the following formula might suit:
=IF(A2="Y",C$1*SUM(B:B)*B2/SUMIF(A:A,"=Y",B:B)/SUM(B:B),(1-C$1)*SUM(B:B)*B2/SUMIF(A:A,"=n",B:B)/SUM(B:B))
copied down to suit and assuming a layout as shown:

Related

TRUE/FALSE ← VLOOKUP ← Identify the ROW! of the first negative value within a column

Firstly, we have an array of predetermined factors, ie. V-Z;
their attributes are 3, the first two (•xM) multiplied giving the 3rd.
f ... factors
• ... cap, the values in the data set may increase max
m ... fixed multiplier
p ... let's call it power
This is a separate, standalone array .. we'd access with eg. VLOOKUP
f • m pwr
V 1 9 9
W 2 8 16
X 3 7 21
Y 4 6 24
Z 5 5 25
—————————————————————————————————————————————
Then we have 6 columns, in which the actual data to be processed is in, & thereof derive the next-level result, based on the interaction of both samples introduced.
In addition, there are added two columns, for balance & profit.
Here's a short, 6-row data sample:
f • m bal profit
V 2 3 377 1
Y 2 3 156 7
Y 1 1 122 0
X 1 2 -27 2
Z 3 3 223 3
—————————————————————————————————————————————
Ultimately, starting at the end, we are comparing IF -27 inverted → so 27 is within the X's power range ie. 21 (as per the first sample) .. which is then fed into a bigger formula, beyond the scope of this post.
This can be done with VLOOKUP, all fine by now.
—————————————————————————————————————————————
To get to that .. for the working example, we are focusing coincidentally on row5, since that's the one with the first negative value in the 'balance' column, so ..
on factorX = which factor exactly is to us unknown &
balance -27 = which we have to locate amongst potentially dozens to hundreds of rows.
Why!?
Once we know that the factor is X, based on the * & multiplier pertaining to it, then we also know which 'power' (top array) to compare -27, as the identified first negative value in the balance column, to.
Is that clear?
I'd like to know the formula on how to achieve that, & (get to) move on with the broader-scope work.
—————————————————————————————————————————————
The main issue for me is not knowing how to identify the first negative or row -27 pertains to, then having that piece of information how to leverage it to get the X or identify the factor type, especially since its positioned left of the latter & to the best of my knowledge I cannot use negative column index number (so, latter even if possible is out of the question anyway).
To recap;
IF(21>27) = IF(-21<-27)
27 → LOCATE ROW with the first negative number (-27)
21 → IDENTIFY the FACTOR TYPE, same row as (-27)
→ VLOOKUP pwr, based on factor type identified (top array, 4th column right)
→ invert either 21 to a negative number or (-27) to the positive number
= TRUE/FALSE
Guessing your columns I'll say your first chart is in columns A to D, and the second in columns G to K
You could find the letter of that factor with something like this:
=INDEX(G:G,XMATCH(TRUE,INDEX(J:J<0)))
INDEX(J:J<0) converts that column to TRUE and FALSE depending on being negative or not and with XMATCH you find the first TRUE. You could then use that in VLOOKUP:
=VLOOKUP(INDEX(G:G,XMATCH(TRUE,INDEX(J:J<0))),A:D,4,0)
That would return the 21. You can use the first concept too to find the the -27 and with ABS have its "positive value"
=VLOOKUP(INDEX(G:G,XMATCH(TRUE,INDEX(J:J<0))),A:D,4,0) > INDEX(J:J,XMATCH(TRUE,INDEX(J:J<0)))
That should return true or false in the comparison

VLookup with Multiple Ranges

I'm trying to make a formula that would do the following: There are say 10 categories 1-10, given a number x and y, the line is in category 3 if and only if x is between 1 and 2 and y is between 5-7 for example. I don't know how to use VLookup given the multiple conditions and the two ranges that are completely different and not in a sequential order.
I tried using index match:
=INDEX(B5:B15,MATCH(1,IF(AND(K5>=C5:C15,K5<=D5:D15),1,0)*IF(AND(L5>=E5:E15,L5<=F5:F15),1,0),0))
but this returns an error where column B are the categories, K5 and L5 are x and y respectively and column C is the lower bounds for x per category with D as upper bounds and same for E and F for y.
Here's a mock representation of the data and rules:
Data
x y category
1.2 12 1
1.5 5 2
0.98 23 3
.
.
.
Rules
Category X-LB X-UB Y-LB Y-UB
1 1 2 9 15
2 1.5 1.7 1 9
3 0.8 1 20 23
.
.
.
LB is lower bound and UB is upper bound. For example given x and y above using the rules table we find the expected return column.
Thank you,
If you have only category which will fit the bill in each case, one way is to use SUMPRODUCT.
Formula in C2 and down is
=SUMPRODUCT(($B$10:$B$12<=A2)*($C$10:$C$12>=A2)*($D$10:$D$12<=B2)*($E$10:$E$12>=B2)*($A$10:$A$12))
In M5, copied down :
=INDEX($B$5:$B$15,MATCH(1,INDEX(($K5>=$C$5:$C$15)*($K5<=$D$5:$D$15)*($L5>=$E$5:$E$15)*($L5<=$F$5:$F$15),0),0))
Or,
Another shorter option.
Using SUMIFS function, formula in M5 copied down :
=SUMIFS($B:$B,$C:$C,"<="&$K5,$D:$D,">="&$K5,$E:$E,"<="&$L5,$F:$F,">="&$L5)

Manipulating function sample sizes in Excel

Suppose I had two time series consisting of weekly data points, and I want to compute the covariance of the time series for the last n weeks using the covariance function in Excel.
Would it be possible to set this scenario up in such a way that a certain cell contains the number of weeks of data I want to compute the covariance for?
That is, changing the cell element to k would lead to the already computed covariance for n weeks to change to the covariance of the data series for the last k weeks?
You decided that sample data was not important so here is some.
date nmbr
03-30-2017 4
04-04-2017 4
04-07-2017 2
04-09-2017 2
04-12-2017 1
04-15-2017 4
04-18-2017 1
04-21-2017 2
04-24-2017 1
04-26-2017 3
04-30-2017 4
05-02-2017 5
05-07-2017 4
05-09-2017 2
05-10-2017 1
05-12-2017 5
05-14-2017 4
My crystal ball tells me that this question is not so much about Excel's COVARIANCE.P or COVARIANCE.S but about limiting date related data. To this end, I'll simply SUM 4 weeks of data.
The formulas needed in E2:H2 (see supplied image) are:
=TODAY()
4
=FLOOR(E2-(F2*7), 7)+1
=SUM(INDEX(B:B, MATCH(G2, A:A)+ISNA(MATCH(G2, A:A, 0))):INDEX(B:B, MATCH(1E+99, A:A)))
Note that the dates are in ascending order.

Excel formula to apply penalty column to ranking

I have thought long and hard about this, but I can't find a solution to what I believe is quite a simple problem.
I have a table of results, where sometimes someone will be given a penalty of a varying amount. This is entered into the penalty column (Col C).
I need a formula which checks if there is an entry into the penalty column and applies it, not only to that row, but to the number of subsequent rows which are affected, depending on the severity of the penalty.
I have tried to see if this is possible by referencing the penalty against the 'ROW()' function but have not been able to achieve the desired effect.
Col D shows the desired output of the formula.
Col E is included for reference only, to show the desired effect on each row.
Col A Col B Col C Col D Col E
Pos Name Penalty New Pos Change
1 Jack 1 0
2 Matt 2 0
3 Daniel 2 5 +2
4 Gordon 3 -1
5 Phillip 4 -1
6 Günther 6 0
7 Johann 3 10 +3
8 Alain 7 -1
9 John 8 -1
10 Gianmaria 9 -1
The big issue is, if someone is handed a big penalty, for example '10' then it affects the following ten rows. I can't work out how to include this variable logic...
I would be interested to hear the approach of others...
You need to use the RANK() function:
Excel RANK Function Examples
In a new column, add the penalty value to the original position, plus a small coeffieient depending on the original position (0.01 per increment perhaps) to move the penalised player below the original person at that position, then in the next column you can RANK() the new column of values (F in my case).
New value is therefore =A2+(IF(C2>0,C2+(0.01*A2)))
Rank is then =RANK(F2,F2:F11,1)
You can combine all the functions into one, but it's clearer to do it in separate columns at first.

Ignore #N/As in Excel LINEST function with multiple independent variables (known_x's)

I am trying to find the equation of a plane of best fit to a set of x,y,z data using the LINEST function. Some of the z data is missing, meaning that there are #N/As in the z column. For example:
A B C
(x) (y) (z)
1 1 1 5.1
2 2 1 5.4
3 3 1 5.7
4 1 2 #N/A
5 2 2 5.2
6 3 2 5.5
7 1 3 4.7
8 2 3 5
9 3 3 5.3
I would like to do =LINEST(C1:C9,A1:B9), but the #N/A causes this to return a value error.
I found a solution for a single independent variable (one column of known_x's, i.e. fitting a line to x,y data), but I have not been able to extend it for two independent variables (two known_x's columns, i.e. fitting a plane to x,y,z data). The solution I found is here: http://www.excelforum.com/excel-general/647448-linest-question.html, and the formula (slightly modified for my application) is:
=LINEST(
N(OFFSET(C1:C9,SMALL(IF(ISNUMBER(C1:C9),ROW(C1:C9)-ROW(C1)),
ROW(INDIRECT("1:"&COUNT(C1:C9)))),0,1)),
N(OFFSET(A1:A9,SMALL(IF(ISNUMBER(C1:C9),ROW(C1:C9)-ROW(C1)),
ROW(INDIRECT("1:"&COUNT(C1:C9)))),0,1)),
)
which is equivalent to =LINEST(C1:C9,A1:A9), ignoring the row containing the #N/A.
The formula from the posted link could probably be adapted but it is unwieldy. Least squares with missing data can be viewed as a regression with weight 1 for numeric values and weight 0 for non-numeric values. Based on this observation you could try this (with Ctrl+Shift+Enter in a 1x3 range):
=LINEST(IF(ISNUMBER(C1:C9),C1:C9,),IF(ISNUMBER(C1:C9),CHOOSE({1,2,3},1,A1:A9,B1:B9),),)
This gives the equation of the plane as z=-0.2x+0.3y+5 which can be checked against the results of using LINEST(C1:C8,A1:B8) with the error row removed.

Resources