Scorecard Question Part 1 - multiple IFs formula - excel-formula

my challenge is of 2 parts (2nd part was already responded by Michal Rosa and Lee Mac).
Here is part 1:
I am working on a scorecard which has series of references. I initially wrote a series of Nested IFs which was very long and also is tedious to change especially when targets change. How can I hardcode or create a formula where I can just change the targets/scoring matrix on the table
Please see sample data:
KRA Data
Say if the agent's LOB is Email, and is in a tenure of 61-90 Days, we return corresponding KRA Rating from the KRA Rating Matrix depending on Actual Score. Like for Agent 1, her Actual Closure score is 18.55 and corresponding KRA rating for her tenure of 61-90 Days is 4.
Similarly, for her TPH, her Actual TPH is 7.02, which assigns a KRA Rating of 3 in the Scorecard Rating Matrix.

You can use nested INDEX / MATCH :
For the outer one (i.e. the one that will find the rating), you use a MATCH which will match the nearest value in the table that is still less than value. You have to modify the look of your rating matrix, instead of putting 4.5 - 5.5, you have to put a single value, i.e. 4.5. You always start with the lowest possible value (typical 0 or minus something), and you end with the highest value.
With the inner one, you extract the array (row) from your matrix that matches both criteria (tenure and LOB), and this array will be fed into the outer match. As it is now, you have to use two formula's, one for the TPH and one for the closure. If your KPI would not be in merged cells, but on each row (like for Tenure and LOB), you could add another condition in the inner MATCH and do everything with a single formula.
The array formula (ctrl+shift+enter) is like this:
{=INDEX($C$1:$F$1;MATCH(D9;INDEX($C$2:$F$5;MATCH(1;($A$2:$A$5=$A9)*($B$2:$B$5=B9);0););1))}
This is a screenshot, starting from A1 (Tenure) and with the formula in F9. I used the colors of your spreadsheet to make it more visual.
This is the same formula with the cell and range references replaces by text so you can better understand and replace with the correct ranges of your worksheet. I hope it is self-explanatory, otherwise just ask:
=INDEX(The_rating;
MATCH(closure-rate_value;
INDEX(Matrix_with_closure-rate_cutoffs;MATCH(1;(LOB_column=LOB_value)*(Tenure_column=Tenure_value);0););1))

Related

When summing a value calculated by multiplying other values, the value is included as a string, however when directly referenced it behaves as a value

I am fairly new to Excel and only using it for a hobby, however I have noticed that when I attempt to add an entire column of values together, there is one value that is not included in the addition. It is also the only 'non-defined' value of the column (i.e. it is calculated using a formula rather than being inputted directly). When I go to edit the formula I see that the value in question (in the below screenshot 24.99), it seems to be a string given the speech marks either side of it, hence why it isn't in the addition.
I am confused as when I reference only that value in a sum, the value is included in the sum, as seen below:
Before it is suggested, I have experimented with using different data types for the value in the cell, including 'Currency', which is what the rest of the cells in the column are, as well as 'Number', 'Accounting', and 'General'. One thing that is strange is that the £ symbol never appears at the front of the number, no matter what data type it's casted as.
For those that are curious, the formula that is used to get the number in the cell B9 is below, where H13 is a number in the form 'Currency', and J13 is a number in the form 'General'.
=IMPRODUCT(H13,J13)
Per this link, a common way to convert text formatted numbers to, well, 'numbers' is to apply a mathematical operation (e.g. if you have ="100", multiplying by 1 will yield 100 - see screenshot)...
Cell constituents
Result
See here for Microsoft's own words "Numbers that are stored as text can cause unexpected results.".
In your example (which I've successfully replicated to aide this soln. - see below), taking 0-B9 (per below screenshot, courtesy your Q above) yields -24.99 in this case as Excel interprets cell B9 as an operand, upon which -1x (as an operation) is applied:
Put another way, you can yield exactly the same (or rather, 'anticipated') result via the summation formula as follows:
Included in the above figure is a depiction of how I have become familiarised with this 'conversion via mathematical operation' trick: it shows how taking 0 + False = 0 (or rather, per the depiction above, 0 + True = 1).
Simple example
Try the following to convince yourself:
Enter ="0", ="1", and ="2" in cells A1:A3 respectively. In the adjacent column/cells (B1:B3), enter =1-A1/A2/A3 as the case may be, i.e.:
Results
Advanced example
Now go ahead and enter (per cell) 3 a's followed by 'b' and 'c' (lowercase) in cells A1:A5. In cell B1 enter the formula "=A1:a5 = "a" (assuming you have Office 365, else use 'Ctrl+shift+enter'). This will return an array of corresponding 'True' and 'False' values for any character (col A) that satisfies the condition '="a"', videlicit:
Of course, summing column B would be futile (well, it returns 0):
However, applying an innocuous mathematical operation '1 *' makes all the difference in the world: you now have an elegant (but time / calculation expensive) way to calculate the count of cells that satisfy the criteria '="a"' - in this case, 3!
Of course, the same could be achieved using any 'neutral' calculation - for instance, adapting the apparent anomaly you've stumbled upon, using sum(0+(A1:A5 = "a") yields the self-same count of 3 ☺
i.e.
Trust this delineates/clarifies (with sufficient detail) the reason why a straight summation (which lack any 'special' operations in its own right) does not include text values, where as taking 0-B9 (per your Q) does (i.e. via the implicit 0-1*B9 operand with respect to B9).
using different data types for the value in the cell, including 'Currency'
What you changed is the number format, not data type.
It's an important difference in Excel, you can change format of cells containing numbers, however if a cell contains text - regardless of it actually represents a number - changing number format will not affect it.
=IMPRODUCT(H13,J13)
This function is used to multiply complex numbers. You could use =H13*J13
when I reference only that value
Functions taking multiple values (SUM, AVERAGE, MIN...) are designed everything not stored as number.
On the other side, if you explicitly include text in a calculation, Excel will try to convert it (e.g. 1 + "9" = 10).
That's what happens in your example too, you don't just include your string in SUM, but first it's added to 0.

Is it possible to return a dynamic formula in VLOOKUP?

I am looking for a possibility to use VLOOKUP in combination with a dynamic formula (or a different solution if possible).
A simplified problem is provided in the image below. Based on a category the number of outlets in a room is calculated. The number of outlets can either be a fixed amount or based on the total area of a room which is provided in a separate column.
What is the best method to apply this to a (much larger) sample?
If "based on total area" is always a x per unitA, then enter it as a proportion, e.g.: 0.1a instead of 1 per 10 m^2, and use a formula that checks for the trailing 'a' and responds accordingly. e.g.:
=IF(RIGHT(VLOOKUP(B2,$F$2:$G$3,2,FALSE),1)="a",CEILING.MATH(SUBSTITUTE(VLOOKUP(B2,$F$2:$G$3,2,FALSE),"a","")*C2),VLOOKUP(B2,$F$2:$G$3,2,FALSE))
(I used "Ceiling" to get the integer value. Replace with Floor or Round as needed).
Probably easier from a formula writing (and readability) POV would be a separate column that holds the a (or rather: a "fixed/proportional" column) and key off of that, but the result is the same.

Match and Conditional Formatting from Matrix Table

I am looking for some decent help with my matrix table, and is there a good or best approach to properly match dependent instances in certain matrix using drop downs.
This picture represents my matrix table (Picture 1):
As you can see there are a lot of instances, but horizontally and vertically they got the same number of "headers". Those "1`s" are representing not compatibility in my case but lets call it simply "match". That is on one sheet that is gonna be populated with some new values from time to time.
On another sheet which is actually sheet for showing the data and their compatibility possibilities is equipped with drop downs. There you got "Groups (Group1, Group2...)" in a sense of main parts and "dependent groups (AA1, BB2..)" as small components that are part of main parts. To avoid misunderstanding here you have explanations, I used for the sake of this example fictional values:
Groups aka. Main Parts
Dependent groups aka. components
As you can see beneath, is my fictional table but exactly the same concept as I should use in my real case.
I PUT AN EXPLANATION IN THE PICTURE 2 SO YOU CAN FOLLOW ALONG AND SEE EXACTLY WHERE/WHAT I DID!
What I used firstly there are =match functions, one for vertical position (A3) and one for horizontal (B4). This boolean row is done using =or(index) but reffering to the match positions as you can see. And from there I should use true/false for coloring my group boxes in a case compatibility is possible - thats all the science.
So, my question is if there is another approach to this problem? As you can see I have 3 different rows of functions at one place, or imagine if I will have more "groups" that can rise in many more rows and calculations.
Picture 2
EDITED:
This is screenshot of the original sheet, I just hid some rows that were with Infos that is reason the number is not consistent. As you can see it is almost the same as dummy example I provided above. Underneath every "box" you got three rows of calculations as I mentioned before. The two times number "2" that you see here is the position of some value that I found using =match function, one is for horizontal and another for vertical lookup. In this case it is model type, 070FX is position 2, 100FX is 3 and 200FX is 4th position in the matrix table, and so on for all the other groups. And those groups (Model, Endpoint, Gas sensor...) are defined separately on another sheet where I had to make unique list and dependent list so I can reference those to my drop down list.
EDIT Nr 4! So this formula I used for true/false:
=SUMPRODUCT(('0359-matrix'!$A$2:$A$101=F10)*(('0359-matrix'!$B$1:$CW$1=$B$10)+('0359-matrix'!$B$1:$CW$1=$C$10)+('0359-matrix'!$B$1:$CW$1=$D$10)+('0359-matrix'!$B$1:$CW$1=$E$10)+('0359-matrix'!$B$1:$CW$1=$F$10)+('0359-matrix'!$B$1:$CW$1=$G$10)+('0359-matrix'!$B$1:$CW$1=$H$10)+('0359-matrix'!$B$1:$CW$1=$I$10)+('0359-matrix'!$B$1:$CW$1=$J$10)+('0359-matrix'!$B$1:$CW$1=$K$10)+('0359-matrix'!$B$1:$CW$1=$L$10)+('0359-matrix'!$B$1:$CW$1=$M$10)+('0359-matrix'!$B$1:$CW$1=$N$10)+('0359-matrix'!$B$1:$CW$1=$O$10)+('0359-matrix'!$B$1:$CW$1=$P$10)+('0359-matrix'!$B$1:$CW$1=$Q$10)+('0359-matrix'!$B$1:$CW$1=F13)+('0359-matrix'!$B$1:$CW$1=G13)+('0359-matrix'!$B$1:$CW$1=H13)+('0359-matrix'!$B$1:$CW$1=I13)+('0359-matrix'!$B$1:$CW$1=J13))*'0359-matrix'!$B$2:$CW$101)>0
I copied only last part, or when it starts from second row..Because it is too long to write whole funciton - it cuts down automatically.
('0359-matrix'!$B$1:$CW$1=$Q$10)+('0359-matrix'!$B$1:$CW$1=$B$13)+('0359-matrix'!$B$1:$CW$1=$C$13)+('0359-matrix'!$B$1:$CW$1=$D$13)+('0359-matrix'!$B$1:$CW$1=$E$13)+('0359-matrix'!$B$1:$CW$1=$F$13))*'0359-matrix'!$B$2:$CW$101)>0
But on marked cells I am getting the same results: B22 - F22 has the same as B21 - F21 (boolean) what shouldnt be like that but to follow color, green is False, it has to be something with an array reference.
Checkout the following. A1 to E5 is the matrix that shows which pieces are incompatible (=1). The others have to be empty or 0.
In cell I8 I used the following formula (and copied it down up to I11):
=SUMPRODUCT(($A$2:$A$5=H8)*(($B$1:$E$1=$H$8)+($B$1:$E$1=$H$9)+($B$1:$E$1=$H$10)+($B$1:$E$1=$H$11))*$B$2:$E$5)
The formula result shows you the amount of incompatibilities a part has. Eg AA1 has one incompatibility with BB2 but BB2 is incompatible with 2 AA1 and CC3.
To get the TRUE/FALSE use the same formula and append >0: like =SUMPRODUCT(…)>0
For any additinonal "group" (Model, Endpoint, …) you need to add another +($B$1:$E$1=$H$12) where $B$1:$E$1 points to your matrix data and $H$12 to your selected group value.
Overview of the formula ranges:
Note that this kind of calculation can only tell the amount of incompatibilites a part has but not the names of the parts that are incompatible.
Edited horizontal version
Formula in the selected cell is
=SUMPRODUCT(($A$2:$A$5=G8)*(($B$1:$E$1=$G$8)+($B$1:$E$1=$H$8)+($B$1:$E$1=$I$8)+($B$1:$E$1=$J$8))*$B$2:$E$5)
you can pull it to the right.

Excel multilevel array formula with partial string matches to sum resultant cells

I've been trying to sort this for over a day now without much luck. I have successfully used SUMIFS, INDEX, MATCH, COUNTIF, "--" etc array functions previously and am not a novice, but also not an expert on these. I can't seem to weave these together correctly, and likely on an altogether incorrect path.
Basically, I am trying to aggregate data from multiple spreadsheets, requiring a mapping of various items (rows) into a canonical form for summing.
The image here shows a representative, but simplified version of my quest. Each "region" on this example spreadsheet (Final..., Mapping, DataSet1, DataSet2) is actually in different spreadsheets, and there are several sheets with 50-150 rows in each xlsx.
Note that the names in Column B are quite arbitrary (meaning not all P1's have an 'x' pattern, like shown here as x1, x2, etc. Do not rely on any pattern in the names, except the x, y , z in the Mapping table are substrings (case insensitive, trailing match) of the names in Column B in the DataSets.
And in the image, the Final Result Table (summed manually) is what I want to compute via(an array) formula: A single formula would be ideal (given I have many spreadsheets from which the monthly data is being pulled from, so I can't readily modify but can create an interim spreadsheet if required, so open to helper columns or helper rows).
Here's the process - For each name (B3-B5) in the Final Result Table, I want to sum the name from it's components as follows:
Lookup all the matches in the Mapping Table (so for P1, the formula =IF($C$10:$C$15=$B3, $B$10:$B$15,"") gives {"x1";"";"";"x2";"";"x3"}.
I then want to search each of x1, x2, and x3 in B19:B26 to get rows 21, 22, 24, 25, 26 in DataSet1 and B31:B35 to get row 32 in DataSet2, to then add up the Jan totals into C3. (Effectively,
C3=C21+C22+C24+C25+C26+C32). Same for P2 and P3, and thru Feb, Mar, ...
I am stuck on how to remove blank or 0 or Div0 or such "error rows" from the interim result in 2, and also need to use 2 arrays of different sizes (3 valid rows in example 2 above, ignoring blanks) to search many rows in DataSets. I tried SEARCH("*"&IF($C$10:$C$15=$B3, $B$10:$B$15,""), $B$19:$B$26) but get unexpected results. I have tried to replace text in the interim result {"x1";"";"";"x2";"";"x3"} with TRUE/FALSE, and 1/0, etc. to help with INDEX or MATCH, but am stymied by errors in downstream ("surrounding") formulas.
Thanks in advance.
Here is a solution without resorting to nasty (imo) CSE formulas.
= SUMPRODUCT($C$19:$F$26*(COUNTIFS($B$10:$B$15, RIGHT($B$19:$B$26,2),$C$10:$C$15,$B3)>0)*($C$18:$F$18=C$2))
+
SUMPRODUCT($C$31:$F$35*(COUNTIFS($B$10:$B$15, RIGHT($B$31:$B$35,2),$C$10:$C$15,$B3)>0)*($C$30:$F$30=C$2))
There is one SUMPRODUCT for each data set. If possible, it would be better to put all your data sets into a single table with a column identify which data set it is a part of.
The way it works is to takes each values in your data set and multiplies it by whether the 2 right most character appear in your mapping table for that P code, multiplied by whether the value is in the correct month. So it returns 0 if either of those conditions are false. Then returns the sum.
UPDATE IN RESPONSE TO OP COMMENTS
If, the X,Y, Z codes are not always 2 digits but the first part is ALWAYS 8 digits, you can easily amend the:
RIGHT($B$19:$B$26,2)
to be:
RIGHT($B$19:$B$26,LEN($B$19:$B$26)-8)
Making the formula for the first data set:
=SUMPRODUCT($C$19:$F$26*(COUNTIFS($B$10:$B$15, RIGHT($B$19:$B$26,LEN($B$19:$B$26)-8),$C$10:$C$15,$B3)>0)*($C$18:$F$18=C$2))
And you can amend for other data sets and simply add them together.
Nice challenge! Are you willing to drop all your tables (DataSet1, DataSet2...) into one spreadsheet, so that we can refer just one single range for each month?
Here's one solution (hopefully a good starting point) - array formula (Ctrl+Shift+Enter):
=SUMPRODUCT(IFERROR(IF(TRANSPOSE(IF($B3=$C$10:$C$15,$B$10:$B$15,""))=RIGHT($B$18:$B$36,2),C$18:C$36,0),0))

Ranking with subsets

I'm trying to rank values and have managed to work out how to sort ties. My data looks at the total number of entries, ranks based on that and if there is a tie it looks to the next column of values to sort them out. However, I have two classes (East and West I've called them) of data within my dataset and want to rank them both separately (but stick to the rules above). So, if I had seven entries, 3 of them West and 4 of the East, I want West to have ranking 1,2,3 based on all the values that lie in that subset and East would have ranking 1,2,3,4. Can you explain what your formula is doing so I can understand how to apply your answer better in the future.
Effectively I'm asking what formula needs to go in achieve my result.
Cheers
Paul
There are a few related ways to do this, most involving SUMPRODUCT. If you don't like the solution below and would like to research other ways/explanations, try searching for "rankif".
The function looks up the Class and Value columns and, for every value in those columns, returns a TRUE or 1 if the current Class is a match AND if its Value is larger than the current Value, False or 0 if otherwise. The SUM adds up all these 1s, and the 1+ is for decoration. Remember to enter as an array formula using Ctrl+Shift+Enter before dragging down.
I used the array formula and SUM above to explain, but the following also works and might even be faster since it's not an array formula. It's the same idea, except we hijack SUMPRODUCT's ability to spit out a single value from an array.
=1+SUMPRODUCT(($A$2:$A$8=A2)*($B$2:$B$8>B2))
EDIT
To extend the rank-if, you could add more subsets to rank by multiplying more conditions:
You can also easily add tiebreakers by adding another SUMPRODUCT to treat the ties as an additional subset:
The first SUMPRODUCT is the 'base rank', while the second SUMPRODUCT is tiebreaker #1.

Resources