I'm trying to use the formula =MAX(FREQUENCY(IF(T2:AC2>1,ROW(T2:AC2)),IF(T2:AC21>=1,ROW(T2:AC2))))to find more than one maximum value before a zero from a range.
ROW has this values
1 2 0 1 2 3 4 5 6 0
I want a formula/formulas that will return 2 and 6
Thank you
You can use this formula
=LET(list,
FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(CONCAT(A1:A16),"d","l"),"l","</s><s>")&"</s></t>","//s"),
LEN(list)-LEN(SUBSTITUTE(list,"w","")))
Got this working:
=IFERROR(INDEX(R:R,AGGREGATE(15,6,ROW(R$3:R$100)/((R$3:R$1100=0)*(R$2:R99<>0)),ROWS(S$3:S3))-1),"")
Assuming the data is in column R, put the formula in column S. Link: https://www.mrexcel.com/board/threads/find-more-than-one-maximum-value-before-a-zero.1188659/post-5793250.
Related
There have been answers previously explaining how to SUM only the first instance. E.g.
=SUMPRODUCT( (A2:A25<>"") / COUNTIF(A2:A25,A2:A25&""),D2:D25)
When looking to only SUM the values in D on the first instance of a label in A. How would you add a criteria to this formula? i.e. In C the values must equal to "yes"?
Use COUNTIFS with a changing range to see if it is the first then use SUMIFS:
=IF(COUNTIFS($A$1:A2,A2)=1,SUMIFS(D:D,C:C,"yes",A:A,A2),"")
You can use SUMIFS.
For example: =SUMIFS($D$2:$D$25, $C$2:$C$25, "yes", $A$2:$A$25, "<>"&"")
Suppose the following series:
I am trying to find the latest non 1 value that precedes the latest 1.
In this case it should return 3 and not 4.
1 being the minimum value I have tried to use MATCH(MIN(range),range,0) and add 1 to get the value I needed, but the minimum function gets stuck on the first occurrence of the minimum.
Try
=INDEX(B1:P1,1,MATCH(1,(OFFSET(B1:P1,,-1)=1)*(B1:P1>1),0))
Where B1:P1 is your data range. Of course it is an array formula (SHIFT+ENTER).
Hope that helps.
I can't see a short and snappy answer to this but here is one suggestion assuming the data starts in column A
=INDEX(2:2,AGGREGATE(15,6,COLUMN(INDEX(2:2,MATCH(1,2:2,0)):INDEX(2:2,MATCH(999,2:2)))/(INDEX(2:2,MATCH(1,2:2,0)):INDEX(2:2,MATCH(999,2:2))>1),1))
If the range didn't start in column A, you would have to subtract the number of the column before the first column of the range from the column number returned by the AGGREGATE to get the correct index value relative to the start of the array e.g. for B2:Z2
=INDEX(B2:Z2,AGGREGATE(15,6,COLUMN(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):INDEX(B2:Z2,MATCH(999,B2:Z2)))/(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):INDEX(B2:Z2,MATCH(999,B2:Z2))>1),1)-COLUMN(A:A))
To be honest it wouldn't be worth using a MATCH to find the last number in the range unless the number of cells in the range was very large, so the formula for B2:Z2 would just be
=INDEX(B2:Z2,AGGREGATE(15,6,COLUMN(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):Z2)/(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):Z2>1),1)-COLUMN(A:A))
Formula starting column A
Formula starting at column B
How can I find the minimum value in columns B:C in the table below if the volume is <= 10.
The expected result is in yellow.
Regards,
Elio Fernandes
Either:
=AGGREGATE(15,6,C2:C9/(A2:B9<=10),1)
or, array formula**:
=MIN(IF(A2:B9<=10,C2:C9))
If there may be blank cells in B2:C9:
=AGGREGATE(15,6,1/(1/C2:C9)/(A2:B9<=10),1)
or:
=MIN(IF(A2:B9<=10,IF(ISNUMBER(C2:C9),C2:C9)))
Regards
You can use this formula to get the minimum value (Which according to me should be 20 in your data set)
=MIN(1/AGGREGATE(14,6,1/((A2:A9<=10)*B2:B9),1),1/AGGREGATE(14,6,1/((A2:A9<=10)*C2:C9),1))
for each additional column(say D) you will have to add the formula 1/AGGREGATE(14,6,1/((A2:A9<=10)*D2:D9),1) inside the MIN() formula.
Looking for a better way to do this.
EDIT:
Alternatively you could add a new row below your data. for each column you add the below formula to get the min for that column
=1/AGGREGATE(14,6,1/(($A$2:$A$9<=10)*B2:B9),1)
Now you can drag this formula to as many columns you want. Take the MIN() of this row to get the overall minimum.
I have a list of 4000 different price values in one column. I want to calculate the average of the first X values in the column and display the result in cell "B21". The value of X can be changed and is located in cell "B20". How would I use excel functions to do this? Perhaps Average and Offset?
This will do it:
=AVERAGE(A1:INDEX(A:A,B20))
Note that a 0 or blank in B20 will average the whole column. You could filter that out with an IF statement:
=IF(B20=0,"NA",AVERAGE(A1:INDEX(A:A,B20)))
As Barry mentioned in his comment, I chose INDEX because it's not as volatile as OFFSET and INDIRECT.
How about:
=AVERAGE(INDIRECT("A1:A" & B20))
I'll throw my hat in the ring as well using the functions the op suggested.
=average(offset(A1,0,0,B20))
As Doug's comment this will also give an error with blanks or 0 in B20.
Gordon
I have two columns of numbers. Both are 1 to 5. I want to count all the cells where the left column value equals the right column value AND the left column value equals a certain value.
I tried this:
=SUM(IF(W2:W13=X2:X13 AND W2:W13=4,1,0))
I've tried pressing Ctrl+Shift+Enter and it adds {} around the formula but that didn't help either.
I think it's the W2:W13 = 4 part that doesn't work
=COUNTIFS(W2:W13,"=4", X2:X13, "=4")
You can use the sumif() function:
SumIf( range, criteria, sum_range )
it will apply the criteria for each row in the range.
Edit: to count the matches, you can use sum_range = 1 or use the Countif() function suggested by Ben in his answer
Have you considered a third column (C) with the formula IF(A1=B1,1,0) and then summing that third column?
I'm not much of an Excel Expert, but didn't they craeted the COUNTIF(range, criteria) function for this?
Add a third column eg Z2:Z13 with this formula: IF(AND(W2=X2; W2=4); 1; 0)
Then sum that one.
I don't have Excel 2007. So here's how you can do it in Excel 2003:
=COUNT(IF((W2:W14=4)*(X2:X14=4),Y2:Y14))
Since you are looking for a specific value and the column next to it to be the same value, you can just compare both columns to the same value.
The trick to get this to work is after entering the formula you need to hit F2 to go into edit mode and then hit CTRL-SHIFT-ENTER which makes this formula an array formula. This will put {} around the entire formula. Without making this an array formula this formula won't work.
I found this information in the Excel help document titled Count how often a value occurs