Excel, counting positive numbers such that next column is top 10 - arrays

I am looking to count/sum positive numbers in a column given that we are taking only top 10 in next column. For e.g.
I am using the formula: =SUM(LARGE(IF($E$3:$E$58>0,$F$3:$F$58),ROW(A1:A10)))
But it is summing the top 10 right F column such that E column is positive, which is the other way round. Any help is appreciated.

It doesn't sound as if you need anything more elaborate than a COUNTIFS function and a SUMIFS function. The LARGE function can provide a criteria to govern what is included in the count or sum. You've provided no row numbers so I will just use full column references.
     
The formulas are in the image much as your sample data was. As you can see, I used a greater than zero to determine what is a positive number. These are not array formulas. I was a little confused why you were asking for a count as your description seemed to refer to the Top 10. Maybe you can transcribe this for your own purposes.

Related

Makearray function in Office Excel unable to generate proper amount of columns for the array

I am using Office 365 currently and I want to make a visualization tools using MAKEARRAY functions.
For example, if I want to display sequential of 32 items, I would display it in this way:
I use the following formula of Makearray to generate the custom array for me
Note: Formula is pasted at cell value F3 .
=MAKEARRAY(ROUNDUP(B2/B3,0),IF(E3#=ROUNDUP(B2/B3,0),MOD(B2,B3),B3),LAMBDA(row,col,"O"))
but it seems like after debugging, this part of the formula are giving it the problem are these
IF(E3#=ROUNDUP(B2/B3,0),MOD(B2,B3),B3)
as I debugging the formula separately as shown in picture below, it can generate the correct amount of columns as it is supposed to.
Note: Generate exactly same amount to the no of columns if row number is not matching;
Generate modulus remainder formula if row number is matching to roundup of no. of items divided by no. of columns.
But in the end, I put that problematic formula back into the MAKEARRAY function just give only a single columns, which seems like it is quite wrong.
May I know why it display single columns even though by right, it should display the correct amount of no. of columns?
What about:
Formula in C1:
=WRAPROWS(INDEX("O",SEQUENCE(A1,,,0)),A2,"")
Or rather:
=WRAPROWS(EXPAND("O",A1,,"O"),A2,"")
MAKEARRAY does not expect an array in the number of columns. It is a set number. It will iterate the number of rows and number of columns to create the array. It will always be square and not jagged.
So you need to do the math to change the value:
=MAKEARRAY(ROUNDUP(B2/B3,0),B3,LAMBDA(rw,clm,IF(10*(rw-1)+clm>B2,"","O")))
Now as soon as the space is greater than the 32 it puts in "" instead of "O"

Google Sheets: Average of every other column

I’ve looked at similar questions and I think I’m close to a working solution, but it’s giving me the wrong answer. I have a spreadsheet in Google Sheets with data in all columns, but every other cell contains a dollar value and I need only the average of those cells. They start (in this version) on cell G3 and continue through most of row 3, then I intend to copy the formula to other rows with the same cells in those rows needing to be averaged as well, so if it’ll adjust as I copy that’ll be best. Here’s what I’ve worked up so far:
=AVERAGEIF(ArrayFormula(mod(column(G3:3),2)),”>0”)
It’s returning 1 as the result, when it should be about 1500. If I change the 2 to another number, the result increases with it, so I think something in mod or column is being done wrong, but I don’t have enough practice to know where I messed up.
avg of every 2nd column it's done like:
=AVERAGE(FILTER(G3:3, MOD(COLUMN(G3:3)-1, 2)=0))
TIL about the FILTER function. Thanks guys.
There is a way with ArrayFormula. I think you almost got it. I would prefer to add one more argument for AVERAGEIF to specify the range to average. I don't know if it defaults to the range in the condition.
And I would do the modulo on the difference between a column and the first column. I guess for your question it isn't needed as all column numbers are either odd or even. But using the difference is a general purpose way to apply the concept to say every nth column.
The modulo 2 of any column number with be 0 or 1. So instead of using an inequality just use 0 or 1. From your formula it looks like your dollar values must be in odd columns so the result of the modulo should be 1. But I think if you are starting at G3 then taking the column difference before applying Mod 2 changes the desired result to 0. But of course to switch to the other column change the 0 to a 1.
=AVERAGEIF(ArrayFormula(mod((COLUMN(G3:3)-COLUMN(G3)),2)),0,G3:3)

Excel maximum difference between consecutive values in array

I have an array of numbers:
46.50, 46.50, 46.50, 50.00, 60.00, 57.00, 50.00, 48.00, 44.00, 42.00
I'd like to create a formula that finds the maximum positive difference between two consecutive pairs. So in the above example, the intermediate calculation would be:
0,0,-3.50,-10.00,3.00,7.00,2.00,4.00,2.00
Therefore the answer would be 7.00
Going to go with a basic array formula for this one. Aussuming your data is layed out as per the image below, used to offset ranges and subtract one range from the other. Then take the maximum of those results. This can be achieved using the following formula entered as an array. meaning you need to confirm it with CTRL+SHIFT+ENTER. You will know you have done it right when {} show up around your formula. They cannot be added manually.
=MAX(B3:B11-B4:B12)
as an alternative non array formula you can got with AGGREGATE which will perform array like calculations:
=AGGREGATE(14,6,B3:B11-B4:B12,1)
The above formulas will provide you with the largest positive difference. If how ever you need to know the largest difference, then -10 is a larger difference than 7. Its just in the opposite direction. To find this you would need to add ABS to the above equations as follows:
=MAX(ABS(B3:B11-B4:B12))
OR
=AGGREGATE(14,6,ABS(B3:B11-B4:B12),1)
Use an array formaula. If your values are in column A (rows 1 to 10 in this case), use
=MAX(A1:A9-A2:A10)
And enter it with CTRL-SHIFT-ENTER instead of just Enter.

make link to column excluding certain value(s) in excel

Ok,. Here, I have a column of values, which are ascending order numbers. At certain points, sequence is broken and 0 's are replacing the values. Its like , 1,2,3,0,0,6,0,8,... in continuous cells of a column. Now, I want another column to be linked to this one, but instead of the zeros, the next non zero number appearing on the sequence should be shown. ie. a link to array which exclude a certain value and skips its place. I want it to be in realtime, either using formulas or using macros. Thank you in advance.
OK I got it now (hopefully)... what you are looking for is doable with a simple "SMALL"-function like:
D2: =IFERROR(SMALL(A:A,COUNTIF(A:A,0)+ROW()-1),"")
E2: =IFERROR(INDEX(B:B,MATCH(D2,A:A,0)),"")
The formulas then simply can be copied down. The -1 is the offset for not starting in row 1 (starting at row 25 would need -24). The COUNTIF is simply for skipping out the 0's.
Should be pretty much self explaining, but if you still have any questions, just ask :)
Starting with a blank or zero in C1, and assuming the list of numbers starts in A2 and numbers aren't repeated, you could look for the next number which is greater than the number above starting in C2:-
=IFERROR(INDEX(A$2:A$10,MATCH(TRUE,INDEX(A$2:A$10>C1,0),0)),"")
Is this what you meant?

how do you find the nth lowest number in an array when numbers repeat themselves?

I am trying to find the second lowest cost in this list. Clearly, it is $547, but when I put the formula in: =SMALL(F2:F31, 2) I get $488.00, and I am guessing this is because $488 repeats itself a number of times and so it is the second number in the list of numbers to be the smallest?
What formula should I put in to get the second smallest number, despite repeats?
What is the purpose of this? The end result? Do you seek automation or this is adhoc?
If this is adhoc, you can do:
1. copy column with numbers
2. Paste copied column into new sheet
3. Use Remove Duplicates functionality (Data tab) on this column to remove repetitions
4. Use your formula
Also, you can do this with one formula :
=SMALL(F2:F31, COUNTIF(F2:F31, MIN(F2:F31)) + 1)
As long as you only want the second smallest number, and you only have 2 digits of significant influence, you can do this fairly effectively without creating additional arrays of data, or using Array Formulas, as long as you can re-order from largest to smallest, instead of smallest to largest.
First, find the smallest number, which is simply:
=MIN(F:F)
Then, subtract 1 penny from that amount. We can now use price-is-right-rules searching to find the closest number, utilizing the next-best feature of the MATCH function, as follows:
=INDEX(F:F,MATCH(MIN(F:F)+0.01,F:F,-1))
This will take the smallest number in column F, and add .01 to it. Using -1 as the 3rd argument in the MIN function forces MIN to accept the next best alternative if this amount is not matched exactly.
Only because I figure based on your last post we are headed this way. I would as I said in that post make a unique list of all your states and counties.
Then building on #Andrew formula, which should be the one marked as correct, with COUNTIFS() as the k value in the SMALL():
=SMALL(IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F)),COUNTIFS(DATA!A:A,A2,DATA!B:B,B2,DATA!F:F,MIN(IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F))))+1)
This will give you a clean list of the second value.
Then to find the Insurance company that goes with the quote use:
=INDEX(DATA!E:E,MATCH(SMALL(IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F)),COUNTIFS(DATA!A:A,A2,DATA!B:B,B2,DATA!F:F,MIN(IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F))))+1),IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F)),0))
Put them in the second row. These are both Array formulas and will need to be confirmed with ctrl-shift-enter. Then they can be copied down as far as needed.

Resources