I have a challenge to count the number of instances that consecutive values are greater than 12. I want to count the number of times that are consecutive in total. It might be easier to explain with an example of the data.
Data: 12.1, 12.3,13, 11, 10, 15, 13, 12.1, 11, 12.2, 13.1
Should return 5 - ie 5 times that 2 numbers next to one another are >12. NOT 3, where there 3 'groups' of cells all greater than 12 in each cell.
Current formula I am working with is:
=SUM(INT(FREQUENCY(IF(data>12,COLUMN(data)),IF(data<12,COLUMN(data)))>=2))
Where "data" is the range I am trying to count.
Assuming your data is in A1 to K1, this should work
{=SUM((A1:K1>12)*(B1:L1>12))}
Note that the {...} indicate an array formula, so copy the formula without them and enter with CTRL + SHIFT + ENTER.
The * is equivalent to AND in an array, so basically this formula sums up all instances, where both conditions within parenthesis are TRUE (TRUE = 1).
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 have a list of values between 1 and 100, essentially a sort of ranking that occassionally skips a few numbers (for example, the first ten values are 2, 6, 6, 10, 10, 10, 10, 11, 12, 13). They're ordered ascendingly, so every number will be either higher than or equal to the number above it. Now, I wish to remove all the duplicates from this list while remaining between 1 and 100. So, for example, for the values above, something like 2, 6, 7, 10, 11, 12, 13, 14, 15, 16 would work or 2, 6, 7, 8, 9, 10, 11, 12, 13, 14. However, the formulas I've tried so far will either go over 100, go under 1, or create circular references.
Given the nature of the list, there's very little chance of the amount of values exceeding 100, so if that possibility can be accounted for, it'd be a nice bonus, but it's not required.
Please create a named range for all your numbers and name it Source. As an alternative, replace the named range Source in my formulas below with the sheet address of the range where you have your numbers.
[C2] =INDEX(Source,MATCH(0,COUNTIF($C$1:$C1,Source),0))
This is an array formula and needs to be confirmed with Ctl + Shift + Enter. Observe that the COUNTIF range is defined one row above the row in which the formula resides. Its formulated with one absolute and one relative end. The end of the range will expand as you copy the formula down.
You can achieve a similar result using the LOOKUP() function. But since MATCH() finds the first instance, LOOKUP() returns the last. Therefore the formula below will return the same sequence in descending order. LOOKUP() is capable of looping on its own and the formula doesn't require array enabling. Just confirm it normally, with only Enter.
[E2] =LOOKUP(2,1/(COUNTIF($E$1:E1,Source)=0),Source)
Observe that the result range is defined with an absolute and relative end, starting above the row of the formula as explained above.
In B2, formula copied down :
=IF(A2="","",IF((COUNTIF(B$1:B1,A2)>0)+(A2=A1),B1+1,A2))
Edit #1
If data have repeated 100 as per OP's comment, then B2 formula become :
=IF((COUNTIF(B$1:B1,100)>0)+(A2=""),"",IF((COUNTIF(B$1:B1,A2)>0)+(A2=A1),B1+1,A2))
Thank you everyone for posting! Thanks to Bosco's original reply, I managed to fiddle around and find the answer myself. The biggest issue I was facing was getting a circular formula error, but by using Bosco's formula as a help column I was able to get it all worked out.
So, the solution holds 3 different columns: Original Data (column A), Help Column (column B) and Final Result (column C).
In the Help Column, I did as suggested, in cell B2 and copied down:
=IF(A2="","",IF((COUNTIF(B$1:B1,A2)>0)+(A2=A1),B1+1,A2))
This would occassionally create results over 100, so in the Final Column I placed the following array formula, which incidentally also accounts for lists longer than 100 entries, in C2 and copied down:
=IF(B2="","",IF(ROW(C2)>101,ROW(C2),IF(AND(B2>=100,B3=""),100,IF($B2:$B$1000>=C3,C3-1,B2))))
As an array formula, this needs to be entered using Ctrl+Shift+Enter.
Thank you very much to everyone who posted replies, I'm sorry for my lack of clarity!
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)
MAX will take a range and tell me the largest number. But what if I wanted to iterate over that range and find the largest two numbers in a row?
For example, if I have the range [0, 2, 5, 6, 9, 3, 8], MAX is 9, but MAX2 is 15 (6+9). MAX3 is 20 (5+6+9).
How would I write MAX2, MAX3, or MAXN in Excel?
Eg: sum 3 largest numbers in A1:A5
=SUM(LARGE(A1:A5,ROW(1:3)))
This is an array formula, so you need to use use Ctrl+Shift+Enter
=IF(AND(A4+A5>=A6+A5, A4+A5>=A3+A4),A4+A5,0)
you could use this formula to find the biggest two numbers in a row.
and this would equate to max2
place your example range in column a and place the formula in b4. drag this from b:1-B:N and the number in b will correspond to the sum of the two highest cells that are next to each other
so if you had n=n you could do
if(and(sum(a2:An)>=sum(a1:A(n-1), sum(a2:An)>=sum(An:A(n+n),sum(a2:an),0)
Thanks for this, the answer helped me solve an even more heinous problem:
=AVERAGE(LARGE(CHOOSE({1,2,3,4,5,6,7,8},(P3),(R3),(T3),(V3),(X3),(Z3),(AB3),(AD3)),ROW($1:$4)))
which let me average the largest of nonadjacent columns for a bunch of students.
you need to push ctrl shift enter to evaluate such an expression
(it's building a table on the fly) – that will wrap curly brackets
{} around it.
the ()s around a cell reference mean that if it's blank
(say a student didn't do a quiz) it gets translated as 0 not #fail
the dollar signs $ are necessary or you can't copy & paste this
into other rows and get the relative stuff to all work.
Not that you asked but I figured someone might...
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