Find out minimum value of specific columns in a row in MS Excel - excel-formula

My table in Excel looks something like this:
abcd 67 94 52 89 24
efgh 23 45 93 54 34
ijkl 64 83 23 45 92
mnop 34 45 10 66 53
This is a student database containing marks obtained in various subjects. I need to calculate the percentage in each row such that out of 5 subjects, the first subject is always included with other 3 subject with maximum marks.
Example: abcd 67 94 52 89 24 75.5%
Here 75.5%=(67+94+52+89)/4=302/4=75.5 where 24 being the lowest has been excluded and 67 has to be taken even if it were the least.
What I require is the least(excluding the first column, of course) of all the columns in that particular row, so that I can sum all the marks and subtract this least marks and finally use it to calculate the percentage.
Any help/suggestion would be appreciated. Thank You.

You'll need to adjust this for your columns, but if you sum the entire range, then subtract the min value after, do a count of the range then subtract one from that, you will be able to get the average.
This code is using the 4 values from column B through F and the 4 values are: 67 94 52 89 24... which results in 75.5
=(SUM(B3:F3)-MIN(C3:F3))/(COUNT(B3:F3)-1)

Related

Excel: How to Use AVERAGEIFS with Multiple Ranges (different columns)

Date
Group A
Group B
Group C
Group A
Sub Group
A1
B1
C1
A2
1/1/2022
35
12
54
10
1/2/2022
43
45
62
93
1/3/2022
76
65
39
48
1/4/2022
12
25
81
18
1/5/2022
89
76
20
26
1/6/2022
23
87
47
17
1/7/2022
56
59
21
53
1/8/2022
29
51
9
68
1/9/2022
76
8
52
35
1/10/2022
36
53
38
53
User Input
Start Dt - 1/1/2022
End Dt - 1/5/2022
Group - Group B
Question
What is the daily average of a Group given the above user input?
Formula
=AVERAGEIFS(INDEX($B$2:$E$11,,MATCH($I$3,$B$1:$E$1,0)), $A$2:$A$11, ">="&$G$3, $A$2:$A$11, "<="&$H$3)
Answer
44.6
User will select a start date, end date and Group.
I want to compute the daily average of that.
The issue arises when there are multiple columns with same group as Averageif takes the first column only.
Issue - How can I find the daily average of Group A for the given dates, given that Group A are in two columns (they can't be combined as there are multiple sub groups)
If you are on Microsoft-365 then can try-
=AVERAGE(FILTER(FILTER(B3:E12,B1:E1=I2),(A3:A12>=H1)*(A3:A12<=H2)))
If you have an older version you could use:
=AVERAGE(
INDEX(A1:E12,
AGGREGATE(15,6,ROW(A3:A12)/(A3:A12>=G3)/(A3:A12<=H3),
ROW(A1:INDEX(A:A,SUMPRODUCT((A3:A12>=G3)*(A3:A12<=H3))))),
AGGREGATE(15,6,COLUMN(B1:E1)/(B1:E1=I3),
TRANSPOSE(ROW(A1:INDEX(A:A,SUMPRODUCT(N(B1:E1=I3))))))))
Entered with ctrl+shift+enter (I think)
In the picture below J3 shows the answer cell. K3 is used to demonstrate the array that is used for the AVERAGE function (a Office 365 spill range).
Another old school approach. User input fields in the formula are referenced using named ranges.
=SUMPRODUCT(($A$3:$A$12>=StartDt)*($A$3:$A$12<=EndDt)
*($B1:$E$1=Group)*($B$3:$E$12))/(COUNTIFS($A$3:$A$12,">="&StartDt,$A$3:$A$12,"<="&EndDt)
*(COUNTIF($B$1:$E$1,Group)))

IF formula too long

I’m trying to create a formula that will display mileage from one place to another.
Example: column one is location combinations (there are 39 locations and multiple combinations)
Eg-sams to Petes, sams to mc d, mc d to sams etc.
Last column with formula would automatically place mileage from point a to point b. Etc
The formula i created was IF but way too long
=IF(B12="SVES TO KHS",11,
IF(B12="SVES TO FRHS",4.1,
IF(B12="SVES TO CHS",6.9,
IF(B12="SVES TO KMS",9.5,
IF(B12="SVES TO ISM",6.2,
IF(B12="SVES TO HM",5.3,
IF(B12="SVES TO FHM",2.4,
IF(B12="SVES TO TSM",7.6,...
Is there a way to shorten the formula?
Best thing to do is create a separate table on sheet 2, in column a have a list of answers "SVES TO ", column b the miles. Then use a vlookup to find the miles
=Vlookup (b12, sheet 2!'a1:b50,2,0)
In this example there are 50 different SVES TO examples, change it to however many you have.
An X-to-Y/Y-to-X distance matrix should be your best bet. While VLOOKUP is good for a one-column-lookup/one-column-retrieval, an INDEX/MATCH/MATCH would be more appropriate for a true matrix.
Assume the folowwing data matrix with destinations along the first row and the first column.
a b c d e f g
a - 40 80 17 37 16 70
b 40 - 48 95 85 8 60
c 80 48 - 24 26 75 73
d 17 95 24 - 14 9 56
e 37 85 26 14 - 91 7
f 16 8 75 9 91 - 78
g 70 60 73 56 7 78 -
Note that distances like c-to-f are the same as f-to-c. (yes, there i a simple formula for this but that is another question). Obviously, any x-to-x or y-to-y should be zero when x = y.
In the sample image below your formula in L2 should be,
=INDEX($B$2:$H$8, MATCH(J2, A$2:A$8, 0), MATCH(K2, B$1:H$1, 0))
The cell and row highlighting were added with a couple simple conditional formats formulas.

How to paste list of values into cells of same columns based on equal intervals in excel?

Like i have list of some numbers and i wanted to paste those values in cells such as A1 which get first value then A9 get second value similary.
I want solution of this without using macros.
A B C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
The value which I have are:-
87
75
67
74
94
99
98
80
64
65
59
77
97
99
so I wanted that value 87 goes to A1 then 75 goes to A9 then 67 goes to A18 and so on..
Start in B1: =A1 just for the first (your list is in A1:A14 for example)
In B2 write the following:
=IF(MOD(ROW(),9)=0,INDEX($A$1:$A$14,INT(ROW()/9)+1,1),"")
Mod(Row(),9)=0 to test if the row is the 9th after the precedent Value
Int(Row()/9) to get from the list in A the next row
IF to return empty
You can drag it down
When finish copy column B paste special Values in a new column and you can work with it normally

How to format a number to appear as percentage in Excel

So lets say I have a few numbers in a sheet
a b c d
1 33 53 23 11
2 42 4 83 64
3 75 3 48 38
4 44 0 22 45
5 2 34 76 6
6
7 Total 85
I would like to display those numbers so that the cell value still holds the original figure (A1 = 33)
but the cell displays both the number and a percentage from the total (B7) eg
a b c d
1 33 (39%) 53 (62%) 23 (27%) 11 (13%)
2 42 (49%) 4 (5%) 83 (98%) 64 (75%)
3 75 (88%) 3 (4%) 48 (56%) 38 (45%)
4 44 (52%) 0 (0%) 22 (26%) 45 (53%)
5 2 (2%) 34 (40%) 76 (89%) 6 (7%)
6
7 Total 85
I know how to format a cell as a percentage, but I can't figure out how to display both original values, the calculated percentage value (value/total*100), but not change the cell value so I could still sum the cells in the end (eg. A6 =SUM(A1:A5) = 196)
Does anyone have an idea? I was hoping there could be a way to duplicate and calculate the figure using text formatting, but I can't get anything to work.
I'm guessing this is a trivial answer and maybe not what you're looking for, but why not just add a column for each of the columns you have now?
a a' b b' c c' d d'
1 33 (39%) 53 (62%) 23 (27%) 11 (13%)
2 42 (49%) 4 (5%) 83 (98%) 64 (75%)
3 75 (88%) 3 (4%) 48 (56%) 38 (45%)
4 44 (52%) 0 (0%) 22 (26%) 45 (53%)
5 2 (2%) 34 (40%) 76 (89%) 6 (7%)
6
7 Total 85
#Ari’s answer seems to meet to meet the requirements in your question, not repeat information more than the example you gave for output requirement and be viable for up to around 8000 or so columns to start with (unless a very old version of Excel) and Jerry’s comment is also correct that what you want to achieve the way you want to achieve it is not possible.
However there are other approaches that might be acceptable substitutes. One is to copy your data and Paste Special with Operation Divide, either elsewhere or over the top of your data. If over the top this either shows the values or the percentages otherwise duplicates your data. Over the top would also require something like Operation Multiply to revert back to values, and reformatting each time if to appear as in your example.
Another is to use a PivotTable with some calculated fields and both are shown below:
I appreciate neither is exactly what you are asking for.

MS Excel: how can I make Max() more efficient?

I have a set of data that looks like this:
ID Value MaxByID
0 32 80
0 80 80
0 4 80
0 68 80
0 6 80
1 32 68
1 54 68
1 56 68
1 68 68
1 44 68
2 54 92
2 52 92
2 92 92
4 68 68
4 52 68
5 74 74
5 22 74
6 52 94
6 52 94
6 46 94
6 94 94
6 56 94
6 14 94
I am using {=MAX(IF(A$2:A$100=A2,B$2:B$100))} to calculate the MaxByID column. However, the dataset has >100k rows, with mostly unique IDs: this seems to be a really inefficient way to do this, as each cell in C:C has to iterate through every cell in A:A.
The ID field is numeric and can be sorted- is there a way of more intelligently finding the MaxByID?
You may be able to use a pivot table to find the maximum for each unique ID: see this link for an example.
Once you have that table, VLOOKUP should enable you to quickly find MaxByID for each ID.
Once you have sorted by ID you could add columns to get the start row number and count for each unique. These 2 numbers allow you to calculate the size and position of the range of Unique values. So then you can use MAX(OFFSET(StartValueCell,StartThisUnique-1,0,CountThisUnique,1)) to get the max
This might be faster
{=IF(A2=A1,C1,MAX(($A$2:$A$24=A2)*($B$2:$B$24)))}
Since your data appears to be sorted, you could see if the ID matches the row above and simply copy the max down.

Resources