Assigning the same value to different cells according to the rank of a matching cell's group - excel

I have an Excel sheet that has values repeating in different rows of the same column (Obtain Marks). In RANKS column I want a grade assigned.
My problem is assigning the same rank to cells having the same Obtain Marks values.
How do I assign the same rank to the same Obtained Marks using an Excel formula?
Obtain Marks RANKS
212 1
212 1
212 1
211 2
210 3
209 4
209 4

Assuming Obtain Marks is in A1 and is sorted in order, if you want grouped by rank then I suggest in B2 and copied down to suit:
=RANK(A2,A$2:A$7,)
If you post includes under RANK the desired output then I suggest instead 1 in B2 and in B3 and copied down to suit:
=IF(A2=A3,B2,B2+1)
Either way each group should have a distinct value.

You can derive a pseudo-RANK.UNIQUE formula by modifying an old standard method of a SUMPRODUCT-style COUNT.UNIQUE formula.
        
The formula in B2 is,
=SUMPRODUCT((A$2:A$8>=A2)/COUNTIF(A$2:A$8, A$2:A$8&""))
Fill down as necessary.

Related

Excel: Formula to count number of unique values in range that match a condition

Consider the hypothetical scenario that you are given a dataset with animals in column A and their weights in column B. Suppose that we want to count the total number of unique weight values within a certain range for a specific animal. In the example below, I'm wanting to count the total number of unique Dolphin weights between 100 and 200. There are three unique weights: 126, 155 and 171. The duplicate weight of 126 is only counted once. The weight of 90 is ignored because it is not within the range. What custom formula can be used to solve this problem?
*This is for Excel 2016
If you are interested to go with SUMPRODUCT() then you can give a try to-
=SUMPRODUCT(((A2:A11=E2)*(B2:B11>=E3)*(B2:B11<=F3))/(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)))
Adapting Scott's second formula:
=SUM(--(FREQUENCY(IF((A2:A11=E2)*(B2:B11>=E3)*(B2:B11<=F3),B2:B11),B2:B11)>0))
where E2 = "Dolphin", E3 = 100, F3 = 200

Excel 2010 columns contain more than one number, need to sum all numbers within the column from multiple rows

Need to SUM Excel columns where 1 row has several numbers within one column
Column B
Row1 68
136
68
Row2 1394
931
33
33
Row3 33
420
350
250
SUM B1:B3 only SUMs first number in cell ?? Help please.
I see no straightforward way to accomplish this.
However, you may flatten the cells into individual values.
Parallel to each cell, issue the formula
=SUBSTITUTE(A1, CHAR(10), ",")
This will make each cell comma separated. Your row one will become
68,136,68
You may then employ text to columns under the Data ribbon using the comma delimiter to give each number its own cell.
Thereafter you may rearrange the numbers and issue your SUM.
1] In C1 and copied down to suit:
="="&SUBSTITUTE(B1,CHAR(10),"+")
2] Copy ColumnC and Paste Special..., Values over the top, Replace All = with =.

Counting unique list of items from range based on criteria from other ranges

I have a file with data in the following format:
text value1 value2
Given value 1 and value 2 meet some criteria, find all the unique text values.
The exact data looks like this:
john 10 20
john 15 35
mark 20 10
mark 25 15
tom 25 40
lee 16 50
If val 1 <=25 and value 2 <=35 the number of unique text = 2 (john and mark)
I have to do this using formulas not filters.
I've been trying combinations of frequency, countifs, sumproducts and a whole range of other methods and can't seem to hit what I'm looking for.
Assuming that text, value1, and value2 are in columns A, B, and C respectively ...
In D1, enter the formula =IF(AND(B1<=25,C1<=35),A1,"") and copy it down the column
Use the formula =SUMPRODUCT((D:D<>"")/COUNTIF(D:D,D:D&"")) for your answer
If you want to list the unique values rather than count them, something like this:-
=IFERROR(INDEX(A$2:A$7,MATCH(0,IF((B$2:B$7>25)+(C$2:C$7>35),1,COUNTIF(E$1:E2,A$2:A$7)),0)),"")
entered as an array formula starting in E2 ( and assuming that you are using columns A,B and C for your data.
See this reference for explanation.
The following formula will do what you are asking:
=SUM(IF(FREQUENCY(IF(B2:B7<=25,IF(C2:C7<=35,MATCH(A2:A7,A2:A7,0),""),""),IF(B2:B7<=25,IF(C2:C7<=35,MATCH(A2:A7,A2:A7,0),""),""))>0,1))
This is an array formula so confirm it with Ctrl-Shift-Enter.
I referred to this webpage.
Also found a shorter one:
=SUM(--(FREQUENCY(IF(B2:B7<=25,IF(C2:C7<=35,COUNTIF(A2:A7,"<"&A2:A7),""),""),COUNTIF(A2:A7,"<"&A2:A7))>0))
Found and modified from hre.

Sum the values of if statements on multiple rows? (Excel)

Say I have a spreadsheet which looks like this:
A B C
1 In Actual Predicted
2 Thing One 300
3 Thing Two 564
4 Thing Three 256 1065
I want to be able to get a sum of the "predicted" column which incorporates values from the "actual" column if the "predicted" value is empty.
I.e. in this case, the value would be 300 + 564 + 1065 = 1929.
I know that I can achieve this for any individual row like so:
IF(C2="",B2,C2)
How do I get a sum of these "if" statements for each individual row?
Thanks.
That can be done with Sumifs() and no helper columns
=SUMIFS(B:B,C:C,"")+SUM(C:C)
Cell D2 = IF(C2="",B2,C2)
Cell D3 = IF(C3="",B3,C3)
...drag / copy to all relevant D cells...
Cell E1 = Sum(D:D)

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