Autofiltered List; cross-row formula - excel

I have a large Autofiltered list (~600 rows), with some of the rows being summary rows that I want to use a UDF to display the lowest priority listed in any of the 'child' cells. I can pass to my formula the right cells, but they are no longer correct if the list is re-ordered in any way. Is there a way to give the formula the right cell and have it recognise that I want that row and only ever that row?
I can do it with a VLOOKUP to look at a hidden column that lists wether the 'child' row matches the right criteria, but with 600 rows and each parent row requiring about a dozen 'child' cells each, it's too slow.

Assuming you have data that looks like this:
Age Gender Priority
52 M 521
53 F 631
78 M 12
81 F 632
then if you wanted to get, say, the lowest priority for males, you could do something like:
={MIN(IF(B2:B5="M", C2:C5, 9999999999999999))}
Note: the {} brackets just indicate that you need to enter the formula as an array formula.
Not 100% sure that answers your question, but hopefully it helps point in a direction that works.

Related

How to get maximum number and name from 2 columns? (Excel)

I have this (example):
Luffy 320
Coby 350
Zoro 180
Now I want to show the max from this info, with number and text (in seperate cells) like this:
col 1 col 2 col 3
1st 350 Coby
2nd 320 Luffy
3rd 180 Zoro
The 2nd Column no problem with the MAX() formula.
For the 3rd column to get the text I've tried the MAX(...) and INDEX(...) formulas but nothings working ...
Can anyone help me?
You first need to get which value is the largest, second largest and so on.
You can use the function LARGE(range, n) for this.
So in your col 2 use this formula:
=LARGE(B:B,1)
=LARGE(B:B,2)
=LARGE(B:B,3)
Assuming B is the column with the values.
Then we need to match this value and get the name
=INDEX(A:A,MATCH("the above calculated cell",B:B,0))
With the above calculated cell I mean the LARGE function cell. And assuming column A is the column with the names.
This should give you a dynamic table that will update when values or names change.
I'm not sure how you manage to get that column 2 using MAX formula since it only outputs the largest number of the inputs and thus can't output 2nd and 3rd position.

Summing the result of nested IF statements in one cell

I've got a pretty complex conditional formula that works for each row of a column (sorry, no excel 2016 IFS) and I would like to get the sum of all instances in a range in one formula without having to make all the rows as a middle step.
Done this quite a bit with other stuff, but for some reason I'm stuck on this one.
The formula per cell is:
=IF((IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<1),0,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<2,1,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<5,2,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<13,3,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<34,4,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<91,5,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<245,6,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<666,7,))))))))
I would like to transform it to a formula that sums everything from the range B:B (or B2:B499) in one go.
I tried some SUM and SUMIF(S) stuff and changing B2 to B:B. That doesn't seem to work.
Oh, if someone has a tip to reduce the nested IF formula to something more readable, that's welcome as well. The idea of the formula is to transform counts to classes.
The datasets that are referred to look like this:
Test_Samples:
Reference_Dataset:
The If statements make up a classification as follows:
0= 0
1= 1
2= 2-4
3= 5-12
4= 13-33
5= 34-90
6= 91-244
7= 245-665
8= 666+
Here you see a count of 2 in "Test_samples", and it is labelled "N" in "Reference_dataset", so the result classifies it as "2" (to avoid confusion: if the count was 5 it would be labelled "3" according to the class criteria).
Say if there are 5 instances with result "2" in the range B2:B499, the sum should be 10.
Create a lookup table like this for your "result value < X" to summarize the If statements into a single lookup table:
Test_Samples B Value
0
1
2
5
13
34
91
245
666
In this example, i've put that on the same worksheet that the formula is placed, in cells A1:A10 (header in A1, so data values in A2:A10). Then you can simplify your formula and make it reference the range of your data like this:
=SUM(MATCH(IF(ISNUMBER(Test_Samples!$B$2:$B$499)*(Reference_Dataset!$H$2:$H$499="N"),Test_Samples!$B$2:$B$499,0),$A$2:$A$10)-1)
Note that this is an array formula and as such must be confirmed with CtrlShiftEnter (instead of just Enter).

Ranking in Excel with multiple criteria

For example, I need to create a merit list of few student based on total marks (column C), then higher marks in math (column B) -
A B C D
-------------------------
Student1 80 220 1
Student2 88 180 3
Student3 90 180 2
Expected merit position is given in column D.
I can use RANK function but I can only do that for one column (total number). If total number of multiple student is equal, I could not find any solution of this.
You can try this one in D1
=COUNTIF($C$1:$C$99,">"&C1)+1+SUMPRODUCT(--($C$1:$C$99=C1),--($B$1:$B$99>B1))
and then copy/fill down.
let me know if this helps.
Explanation
Your first criteria sits in column C, and the second criteria sits in Column B.
Basically, first it is counting the number of entries ($C$1:$C$99) that are bigger than the entry itself ($C1). For the first one in the ranking, you will get zero, therefore you need to add 1 to each result (+1).
Until here, you will get duplicate rankings if you have the same value twice. Therefore you need to add another argument to do some extra calculations based on the second criteria:
To resolve the tie situation, you need to sumproduct two array formulas and add the result to the previous argument, the goal is to find the number of entries that are equal to this entry with $C$1:$C$99=C1 and have a bigger value in the second criteria column $B$1:$B$99>B1:
you add -- to convert TRUE and FALSE to 0s and 1s so that you can multiply them:
SUMPRODUCT(--($C$1:$C$99=C1),--($B$1:$B$99>B1))
the first array is to see how many ties you have in the first criteria. And the second array is to find the number of bigger values than the entry itself.
Note you can add as many entries as you like to your columns, but remember to update the ranges in the formula, currently it is set to 99, you can extend it to as many rows as you want.
Sometimes a helper column will provide a quick and calculation-efficient solution. Adding the math marks to the total marks as a decimal should produce a number that will rank according to your criteria. In an unused column to the right, use this formula in row 2,
=C2+B2/1000
Fill down as necessary. You can now use a conventional RANK function on this helper column like =RANK(D2, D$2:D$9) for your ranking ordinals.
Very simple (or, at least, much more simpler that the one provided by the best answer) 'math' solution: do a linear combination with weights.
Do something like
weighted_marks = 10*colC + colB
then sort weighted marks using simple rank function.
It does solve your problem, bulding the ranking you need.
If you don't like to limit the number of rows or the numbers used in the criteria, Jeeped's approach can be extended. You can use the following formulas in cells D2 to L2, assuming that there are three criteria, the first one in column A, the second one in column B, and the third one in column C:
=RANK($A2,$A:$A,1)
=RANK($B2,$B:$B,1)
=D2*2^27+E2
=RANK(F2,F:F,1)
=RANK($C2,$C:$C,1)
=G2*2^27+H2
=RANK(I2,I:I,1)
=J2*2^27-ROW()
=RANK(K2,K:K,0)
The formulas have to be copied down. The result is in column L. Ties are broken using the row number.
If you like to add a fourth criterion, you can do the following after having the formulas above in place:
Add the new criterion between columns C and D.
Insert three new columns between columns I and J.
Copy columns G:I to the new columns J:L.
Copy column G to column M, overwriting its content.
Change the formula in column L to point to the new criterion.
The factor 2^27 used in the formulas balances the precision of 53 bits available in double-precision numbers. This is enough to cover the row limit of current versions of Excel.

Find all values greater or equal than a certain value

Let's say I have the following table.
Team Score
AA 81
BB 67
CC 44
DD 1.5
JJ 279
LL 49
TT 201
GG 158
MM 32
HH 89
I want to get all teams that scored more than 80 in another table. I tried the Index + Match function as follows but it only gives me the smallest value greater than 80.
Here is the code:
=INDEX($A$2:$A$11,MATCH(80,$B$2:$B$11,-1))
Although I put the values in the lookup_array argument in descending order, this function only gives me one answer: The smallest value greater than 80.
I am trying to do this without having to sort the array and with a huge database mind you. Thank you.
Enter this formula to D2 and press CTRL+SHIFT+ENTER to make it an array formula, then drag it down.
=INDEX($A$1:$A$11,SMALL(IF($B$2:$B$11>=80,ROW($B$2:$B$11)),ROW(1:1)))
See How to look up a value in a list and return multiple corresponding values for details.
How about using an AutoFilter? You're then quite flexible in filtering for values in column score.
If you don't want to use vba, in a third column you could have
=if(B2 > 80, A2, "")
and copy that formula down. You could even put this column of formulas in another tab and either delete the rows that have nothing in them manually or write code that will do that for you.
Create a PivotTable (Team for ROWS, Score for Sigma VALUES, then filter the Sum of Score column for Number Filters, Greater Than..., and 80 next to Show rows where: is greater than *, OK.
* or perhaps is greater than or equal to.

Excel function for ranking duplicate values

I have an excel sheet containing two columns of data that I'd like to rank.
Suppose we have the following:
A B
Franz 58
Daniel 92
Markus 37
Jörg 58
I would like a formula to rank the above data based on column B, and where there are duplicate values (Franz and Jörg) to put the alphabetical name first. What I have at the moment is simply duplicating Franz twice:
=INDEX(Name,MATCH(A2,Points,0))
Can someone advise me of formula / code that will rank the data and arrange duplicate values alphabetically?
Thanks
I would add a helper column in next to your data to help out with ties.
so in column C use
=B1+1/COUNTIF($A$1:$A$4,"<="&A1)/10
This will add on a decimal ranking system based on the name. This assumes that your numbers in column B do not have decimal places, if they do then you will need to increase the 10 on the end of the formula to account for it ie: for 2 decimal places use 1000, 3 : 10000 etc
Use this formula to get the first name
=INDEX(name,MATCH(LARGE(points,1),points,0))
adjust the 1 to 2 for the second name etc
EDIT had the sign around the wrong way
This will rank your data and will not repeat duplicates too:
In C2:
=SUM(1*(b2>$b$2:$b$5))+1+IF(ROW(b2)-ROW($b$2)=0,0,SUM(1*(b2=OFFSET($b$2,0,0,INDEX(ROW(b2)-ROW($b$2)+1,1)-1,1))))
CTRL+SHIFT+ENTER to turn it into an array
Drag these down to C5 and it will not duplicate rank where the name is the same, it will rank them alphabetically if they are the same.
Then if you wanted to order them automatically in order of top performer/score you then do this:
Putting this in E2:
=INDEX(A2:A5,MATCH(LARGE(C2:C5,ROW()-1),C2:C5,0))
...and drag down
Then use a vlookup on your data to return the score putting this in F2:
=vlookup(E2,A2:C5,2,false)
...and drag down
This should give you a table of highest scoring people in score order.
Assuming A2 is the first of the ranked points scores try this version
=INDEX(Name,SMALL(IF(A2=Points,ROW(Points)-MIN(ROW(Points))+1),COUNTIF(A$2:A2,A2)))
confirmed with CTRL+SHIFT+ENTER and copied down
Requires the Name list to be sorted because names with duplicate scores will be listed in the order shown

Resources