I have two columns of data:
A has names in rows 1-5 (Amy, Greg, Matt, Sean, Greg).
B has numbers in rows 1-5 (90, 20, 30, 40, 50).
I want to write an excel function that will give me the number of the row with the name Greg in column A where the number in column B is greater than 25.
I have tried two functions that are not working:
=MATCH("Greg"&TRUE,A1:A6&B1:B6>25,0)
=Match("Greg"&>25,A1:A6&B1:B6,0)
I am pressing ctrl + shift + enter to do an array and it is still not working.
I am unable to sort the values (due to other constraints) so I cannot use the final argument in the match function to achieve the >25 argument.
Try a standard formula AGGREGATE instead of an array formula MATCH.
=aggregate(15, 7, row(a:a)/((a$1:a$6="greg")*(b$1:b$6>25)), 1)
To get possible second, third, etc. matching row numbers, change the 1 at the end to row(1:1) and fill down.
While I don't typically use this style of array formula, your original would have worked as a CSE formula if changed to this,
=MATCH("Greg"&TRUE, A1:A6&(B1:B6>25), 0)
Related
I have included 2 tables below to illustrate my problem.
Table 1
Table 2
I am trying to find a formula that fills rows 140, 143 & 146 (Table 2) from rows 15,16 & 17 (Table 1). There is over 100 so it is quite time consuming to input =B15 etc over and over again.
The offset method e.g. =OFFSET($B$15,(ROW()-1)*3,0) only works when I'm referencing gaps, not trying to fill them.
Essentially, where B140's formula is =B15, B143's will be =B140 + 1 row i.e. B16
Thanks for your help!
If you are trying find value for appropriate month you can use INDEX/MATCH entered as array formula:
=IFERROR(INDEX($B$1:$B$4,MATCH(TRUE,MONTH(A10)=MONTH($A$1:$A$4),0)),"")
Array formula after editing is confirmed by pressing ctrl + shift + enter
Edit
To find by month & year use:
=IFERROR(INDEX($B$1:$B$4,MATCH(1,(MONTH(A10)=MONTH($A$1:$A$4))*(YEAR(A10)=YEAR($A$1:$A$4)),0)),"")
it's also array formula
You can use modulo for this. With the Modulo function, you check if the remainder of the row you're on is divisible by a number (e.g. 3 if you want to copy a value every third row). IF(MOD(ROW(E1);3 = 0)
If that's the case, you can divide by 3 and use for example the Index function to copy the nth value of another location (or another worksheet). If that's not the case, you print "" to get an empty row.
=IF(MOD(ROW(E1);3)=0;INDEX($B$1:$B$4;ROW(E1)/3);"")
If you're working with offsets because the row numbers are not on numbers divisible by three, you could manually offset the rows (and do the same for the division that yields the index row). For example, if you want to have rows 2, 5, 8 etc:
=IF(MOD(ROW(E1)+1;3)=0;INDEX($B$1:$B$4;ROW(E2)+1/3);"")
I am testing my clients for pushups and other exercises.
I want to make excel table where I can put client name, age, number of reps
and to make some formula that can put the new column with given mark. According to
table of ranges.
Table of problem
Use INDEX/MATCH:
As stated, change your Age and number of pushups to just the minimums; 20,30,40,50. And change the order from lowest mark to highest.
And do not skip any lines.
=INDEX($A:$A,MATCH($D11,INDEX($A:$F,0,MATCH($C11,$1:$1))))
Reformat your values, just write your minimum values in the cells (e.g. 20 instead of 20-29) and turn the table around so that 1 is on top and 5 is at the bottom. Then you can use the following formula:
=Indirect(Address(Match(val, Indirect(Address(4, Match(age, A2:F2, 1)) & ":"
& Address(8, Match(age, A2:F2, 1))), 1) + 3, 1))
Quite some formula actually ;) What it does:
Match(age, A2:F2, 1)
returns the column in which the user is to be sorted.
The inner Indirect creates a matrix with that column (e.g. if age is 25, this returns B4:B8).
The outter Match searches the value within this matrix and returns the corresponding row.
With that row and the fixed first column you can get your desired mark.
I wrote this one
=INDEX($A:$A,MATCH($D$11:$D$17,INDEX($A:$F,0,MATCH($C$11:$C$17,1:1))))
table2
Just one more thing,
if I want to be able to keep formula open for more people...formula remain the same,just to change D number and C number?
table3
I would like excel to display the value from table array which has two matching cells com_cd and div_cd using INDEX and MATCH.
I have tried the following formula but it did not work.
=INDEX(K9:K53,MATCH(K3,I9:I53,0),MATCH(K4,J9:J53,0))
Here is a screenshot of the excel sheet with the desired result given according to com_cd and div_cd
Try an array formula (CTRL + SHIFT + ENTER) instead of Enter.
=INDEX(K9:K53,MATCH(K3&K4,I9:I53&J9:J53,0),1)
Not tested but should work.
Will edit later explaining our formula and reason why your formula doesn't work.
Your column_num parameter on the INDEX function cannot sinply provide a secondary row criteria. You need a way to ensure a two column match on the row_num parameter and leave the column_num either blank or as 1 (there is only only column in K9:K53).
The standard formula for K5 should be,
=index(K9:K53, aggregate(15, 6, row(1:45)/((i9:i53=k3)*(j9:j53=k4)), 1))
... or,
=index(K9:K53, min(index(row(1:45)+((i9:i53<>k3)+(j9:j53<>k4))*1e99, , )))
The cell range K9:K53 has a total of 45 rows. The position within K9:K53 will be within ROW(1:45). The first formula forces any non-matching row into an #DIV/0! error state and the AGGREGATE¹ function uses option 6 to ignore errors while retrieving the smallest valid entry with the SMALL sub-function (e.g. 15). The second formula performs the same action by adding 1E+99 (a 1 followed by 99 zeroes) to any non-matching row and taking the smallest matching row with the MIN function.
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.
I need a formula to:
Lookup in its own column for the largest #
only if conditions are met in column 1 and 2
Add 1 to the found number and insert it into the cell
In other words, I want to "filter" my list for rows that have X in column 1 and Y in column 2
and then get the largest number from column 3 within these rows.
Then add 1 to that number.
This can be achieved with a array formula:
{=MAX(IF(($A$1:$A$1000="x")*($B$1:$B$1000="y"),$C$1:$C$1000))+1}
Input:
=MAX(IF(($A$1:$A$1000="x")*($B$1:$B$1000="y"),$C$1:$C$1000))+1
and then [Ctrl]+[Shift]+[Enter] to create a array formula.
Then should there be automatically the curly brackets around the formula.
Greetings
Axel
Standard (non-array) equivalent for MAXIF() functionality would look like:
=MAX(INDEX(C2:C999*(A2:A999="X")*(B2:B999="Y"),,))+1
With your added condition for adding 100 to numbers less than 100 then,
=MAX(INDEX((C2:C999+(C2:C999<100)*100)*(A2:A999="X")*(B2:B999="Y"),,))+1
For versions of Excel that are 2010 and higher, the AGGREGATE¹ function can use the conditional criteria to throw errors then ignore the errors when processing the MAX function.
The standard formulas for E5:E6 are,
=AGGREGATE(14, 6, $C$2:$C$99/(($A$2:$A$99="X")*($B$2:$B$99="Y")), 1)
=AGGREGATE(14, 6, ($C$2:$C$99+($C$2:$C$99<100)*100)/(($A$2:$A$99="X")*($B$2:$B$99="Y")), 1)
In fact, AGGREGATE is using its LARGE sub-function with 1 as the k parameter. Locating the second, third, etc. largest values which meet the criteria is a simple matter of sequencing the k parameter. This can be done with ROW(1:1) then filling the formula down.
¹AGGREGATE¹ was introduced in Excel 2010. It is not available in previous versions.
I am trying to get the average value(s) of some specific entries. I have two columns: A-which is an index column (it goes e.g. from 1 to 1000) and B which is the values column.
I know there is an AVERAGE function and there is an AVERAGE IF function, which will probably help me but I can't seem to get it working the way I need to.
What I need to do is to get the average value of the entries in column B that match this description for the index in column A: 3 + (3*n) in which n >= 0. In this case I need the average of the values in column B, whose entries in A are 3, 6, 9, 12, 15...
Is it possible to do this with excel or do you think it would be better to write a program to get those values?
Thanks for your tips!!
-Jordi
You can use an "array formula" with AVERAGE function, e.g.
=AVERAGE(IF(MOD(A2:A100,3)=0,IF(A2:A100>0,B2:B100)))
confirmed with CTRL+SHIFT+ENTER
To modify according to your comments in simoco's answer you can use this version
=AVERAGE(IF(MOD(A2:A100-11,3)=0,IF(A2:A100-11>=0,B2:B100)))
That will average for 11, 14, 17, 20 etc.
You can use SUMPRODUCT for this:
=SUMPRODUCT((MOD(A1:A1000,3)=0)*B1:B1000)/MAX(1,SUMPRODUCT(1*(MOD(A1:A1000,3)=0)))
Explanation:
MOD(A1,3) gives you 0 only if value in A1 is in form 3*n
MOD(A1:A1000,3)=0 gives you array of true/false values {FALSE,FALSE,TRUE,FALSE,..}
since False is casts to 0 and TRUE casts to 1 when multipliybg by any value, (MOD(A1:A1000,3)=0)*B1:B1000 returns you array of values in column B where corresponding value in column A is in form 3*n (otherwise zero 0): {0,0,12,0,..}
SUMPRODUCT((MOD(A1:A1000,3)=0)*B1:B1000) gives you a sum of thouse values in column B
SUMPRODUCT(1*(MOD(A1:A1000,3)=0)) gives you number of values in form 3*n in column A
and the last thing: MAX(1,SUMPRODUCT(1*(MOD(A1:A1000,3)=0))) prevent you from #DIV/0! error in case when there is no values in column A in form 3*n
UPD:
in general case, say for rule 11+3*n you could use MOD(A1:A1000-11,3)=0