Excel 2016 Select lowest figure from a row if cell above matches condition - excel-formula

I need to select lowest value from a row if cell depending on cell above/below so for these two rows:
45 65 98 58 10 32 56 78 65 78 35 49 67 12 54 65
Y N Y Y N Y Y N Y Y N Y Y N Y Y
the answer would be:
Y=32
N=10
I can find it for the whole row of numbers but just don't know how to select or deselect based on the criteria in the other row

Say you have
In B4 you would write
=MIN( IF( $A$2:$P$2=$A4, $A$1:$P$1, "" ) )
And then press Ctrl+Shift+Enter.
Explaination
IF( $A$2:$P$2=$A4, $A$1:$P$1, "" )
reads as: where $A$2:$P$2 is equal to $A4, consider the adjacent value stored in $A$1:$P$1, otherwise consider an empty string.
min( ... )
reads as: take the minimum of the just-considered array.

Related

Excel - sort 3 numbers MIN MAX and?

I have in Excel 3 columns with numbers, lets say x, y and z.
In a fourt column I want to have them sorted and as text concatunated.
Sample
Col A, Col B, Col C, Col D
12 , 34 , 26 , 122634 < result
54 , 87 , 54 , 545487
I did try using MIN and MAX, but of course how to get the one between.
Any sugestions?
Yes, you can use small (or large). The formula would be:
=SMALL(A2:C2,1)&SMALL(A2:C2,2)&SMALL(A2:C2,3)
where the 1st argument is the range of numbers and the 2nd argument is the "position" on the sorted range.

Count Excel cells in a row until the sum is reached?

I have two rows and want to count the number of cells in the row-2, offset by one column, I need to sum up to reach but not exceed the number in row-1
A B C D E F G
20 39
2 3 15 12 8 10
x y
So "x" should be 3 (2+3+15 < 20)
and "y" should be 4 (3+15+12+8 < 39)
I tried all sorts of formulas, but none worked, this one is supposed to work but doesnt:
=MATCH(A1,INDEX(SUBTOTAL(9,OFFSET(A2,,,,COLUMN(A2:G2))),0))
edit
The actual Excel had slightly different numbers
F D E F G H I J K L M N O P Q R
3404 1409 312971 290486 255425 233206 209780 852766 791217 762958 707437 705119 blank 23141
1135 470 104324 96829 85142 77735 69927 284255 263739 254319 235812 235040 blank 34212
Top row is 44 and the bottom one is 46
The formula I use is :
=MATCH(F44,INDEX(SUBTOTAL(9,OFFSET(F46,,,,COLUMN($F$46:$R$46))),0))
** Edit 2 **
Also - how can I exclude blank cells in this?

How to delete entire row which has empty cell in any column, of a excel sheet containing both texts and numbers

This is my data in excel. How to delete entire row having any empty cell in any column in MATLAB. The sheet contains both texts and numbers,
(col1 col2 col3)
OAS01 0 74
OAS02 0 55
OAS03 0.5 73
OAS04 24
OAS05 21
OAS06 20
OAS07 0 74
OAS08 0 52
OAS09 1 30
OAS01 81
I want to get output like this by deleting of entire and all rows which have any empty cell
(col1 col2 col3)
OAS01 0 74
OAS02 0 55
OAS03 0.5 73
OAS07 0 74
OAS08 0 52
OAS09 1 30
I have tryied but not working well
[num, text, a] = xlsread('data.xlsx');
for i = 1:size(data,1)
if isnan(num(i,1))
a(i,:) =[];
num(i,:) =[];
else
a(i,:) =a(i,:);
num(i,:) =num(i,:);
end
end
xlswrite('newfile.xlsx', a);
Much more elegant way:
T = {'a','b';'','c';'d','e'}
>> T =
'a' 'b'
'' 'c'
'd' 'e'
T(any(cellfun(#isempty,T),2),:) = []
>> T =
'a' 'b'
'd' 'e'
------EDIT-----
OP said it is not working, so I checked, and it is because empty cells gets loaded as NaNs by the xlsread function, so this line should fix it:
[num, text, a] = xlsread('data.xlsx');
a(any(cellfun(#(x) any(isnan(x)),a),2),:) = [];
where a is the 3 by 3 cell that the OP loaded in.
Explanations: cellfun is largely used and well documented, in this particular case, we are interested in setting rows with NaN to [], so we are using matlab's isnan to detect cells which contains NaN, we then wrap the any function outside, which returns a boolean 1 if there is a NaN or a 0 if there isn't a NaN. The outer any generates the boolean index of which (0 is a row with no NaNs and 1 is a row with NaNs) we filter the data on.

Excel: Sum columns and rows if criteria is met

I have a sheet with product names in column I and then dates from there on. For each date there are numbers of how many pieces of a certain product have to be made. I'm trying to sum all those numbers based on a product type, i.e.:
I K L M ...
30.8. 31.8. 1.9. ...
MAD23 2 0 45 ...
MMR32 5 7 33 ...
MAD17 17 56 0 ...
MAD: 120 (2+0+45+17+56+0)
MMR: 45 (5+7+33)
What I'm doing now is sum the row first:
=SUM(K6:GN6)
MAD23 = 47
MMR32 = 45
MAD32 = 73
And then sum those numbers in column J based on part of the product name in column I:
=SUMIF(Sheet1!I6:I775;"MAD*";Sheet1!J6:J775)
MAD = 120
MMR = 45
Is it possible to do this with just one formula per criteria?
Just trying it on those three rows, I get
=SUM($K$6:$M$8*(LEFT($I$6:$I$8,LEN(I10)-1)=LEFT(I10,LEN(I10)-1)))
which is an array formula and must be entered with CtrlShiftEnter
That's assuming that I10 is going to contain some characters followed by a colon and you want to match those with the first characters of I6:I8.
=SUM(IF(MID(Sheet1!I6:I775,1,3)="MAD",Sheet1!k6:gn775,""))
With ctrl +shift+enter

Find what range a number belongs to

Ive written a function to calculate what MARK a student gets, based on a scoring table.
Why does my function work only for A mark?
This what the excel sheet looks like
COLUMN: A B C
Student SCORE MARK
1 adsf 90 A
2 asgfd 89 FALSE
3 A 90 100
4 B 81 89
5 C 71 80
6 D 61 70
7 E 56 60
8 Fx 0 55
This is the function:
{=IF(B1>=$B$3:$B$8,IF(B1<=$C$3:$C$8,$A$3:$A$8))}
I'm using {} brackets for array functions. (CTRL SHIFT ENTER)
Thank you
You're on the right track but your formula is returning an array not a single value. Wrapping the result in LOOKUP should give the desired result:
=LOOKUP("Z",IF(B1>=$B$3:$B$8,IF(B1<=$C$3:$C$8,$A$3:$A$8))
This returns the last matching grade since "Z" is larger than any other text value in the range.
A simpler method is:
=LOOKUP(-B1,-C$3:C$8,A$3:A$8)
The negative signs are needed so that the lookup values are in ascending order.

Resources