I am dealing with a large data set in Excel and need to search a for two neighboring cells in the same column. Usually I would just go through this quickly row by row, but there are around 30,000 rows and probably 1% of those are the neighbors I am looking for. The data is organized temporally, meaning I cannot just sort.
Anyone have an idea if/how this can be done?
You could drag down this formula in column next to your data.
For example, in B3 where column A has data:
=IF(AND(A3<>"",A2<>""),"neighbour above","")
So:
Row A B
1 Data Check
2 10
3 20 neighbour above
4
5 40
6 50 neighbour above
7 60 neighbour above
8
9
10 90
Note B2 first position has no formula. This will highlight neighbouring cells within the column.
How many?
To count how many neighbours, use a countif. so in C1 you can have:
=COUNTIF(B:B, "neighbour above")
which will return 3 in this case above. pairs 10 and 20, 40 and 50, 50 and 60.
You can choose other marker text to flag the neighbour, besides "neighbour above". Just put it in the IF statement.
Related
I've got a table in excel with 10 rows and 10 columns.
The table contains 100 different values between 1 and 3.
I want to find the highest sum of 10 values using only 1 value from each row and 1 from each column.
Do u guys know a function that finds the highest sum? - I've tried to do i manually, but there are to many combinations!
Hope it makes sense.
Thanks in advance:)
My solution builds on what I wrote in the comment, i.e. you first take the maximum value in the 10x10 array, then the maximum in the 9x9 array (excluding the row/column of the first maximum), etc. My solution tries not to do everything in one formula, but I add a few helper columns, and a bit more helper rows (it is fast and dirty, but it works and is easily audited/understandable). You always can do this on a separate worksheet which you could hide if needed.
The screenshot above goes from cell A1 till Y31.
The key formulas:
3.55 is the result of =MAX(B2:K11)
The first gray cell is =IFNA(MATCH($M12;B2:B11;0);""), and you drag this 9 cells to the left. This tries to find a match with the max result in each column of the table;
The 10 left of the 3.55 is =MATCH(TRUE;INDEX(ISNUMBER(P12:Y12);0);0) , and gives the column number of the max value.
The 2 next to the 10 is =INDEX(P12:Y12;N12) and gives the row number of the max value.
The 1 in cell B12 is =IF(OR(B$1=$N12;$A12=$O12);0;1), and creates a 10x10 matrix with a row and column with zeroes where the previous max value was found.
Then you multiply this with the preceding matrix and create a new 10x10 matrix below (enter {=B2:K11*B12:K21} array formula (ctrl+shift+enter) in B22-K31
You then copy/paste rows 12 till 31 9 times below
The 23.02 is the total sum =SUM($M$12:$M$211) from all 10 maximum values and is the result you are looking for. The 10 is just a check with =COUNT($M$12:$M$211)
I need to calculate a column having many cells but I want to not calculate particular cells on condition. For example:
Scenario:
Sr No Marks
1 46
2 33
3 44
4 32
5 11
6 99
7 27
8 98
I want to get the sum of marks but only those cells should be added whom marks are more than 50. What formula should use?
We can use SUMIF here:
=SUMIF(B2:B9, ">50")
This assumes that your Marks column is in column B, and that the first data point is on the second row.
Edit:
If you want to take the average value of marks, where the mark is over 50, then we can also use COUNTIF:
=SUMIF(B2:B9, ">50") / COUNTIF(B2:B9, ">50")
I am currently using the following formula i.e. =IF(COUNTIF($A$1:A2,A2)>4,A2+1,A2) to change the number when I drag this formula downsdie of the rows.
For Example: in this case for every five rows number will change i.e. A1 to A5 it will 1 and A6 to A10 it will be 2 and A11 to A15 it will be 3 etc.
Just wanted to know is it possible to extend the same formula, so along with adding 1 number for every five rows it should also skip 2 numbers for every 60 rows.
For Example: if the 60 row is number 12, then 61st row should be 15 and 120 row will be 26 and 121 row should be 124 etc.
Can someone please help me with this formula?
Thanks for your help in advance.
Number starts at one.
Then get the cell's row number and subtract one. Divide that number by 5 and discard the fractional part (or the remainder). So numbers from 0 to 4 (which are rows 1 through 5) all get an increment of 0, 5 to 9 get 1, and so on. Similar logic with multiples of 60 except that the counting is doubled.
=1 + floor((row()-1)/5, 1) + floor((row()-1)/60, 1) * 2
I have a big data set which has about 9000 rows. I have a few variables for every year from 1960 onwards, and I need to average them in ten year bins. So I have something like:
1
2
3
4
2
3
4
5
Now I need to average the first ten rows, then the next ten, and so on, for all 9000-odd rows. I can do that, but then I get all these rows averaged in the middle which I don't need, and I can't go about deleting those many rows. There has to be an easy way to do this, surely?
Would appreciate any help!
Suppose your data starts from A1. Try this one in B1:
=AVERAGE(INDEX(A:A,1+10*(ROW()-ROW($B$1))):INDEX(A:A,10*(ROW()-ROW($B$1)+1)))
and drag it down.
in B1 it would be =AVERAGE(A1:A10)
in B2 it would be =AVERAGE(A11:A20)
in B3 it would be =AVERAGE(A21:A30)
and so on.
General case
If your data starts from An (where n is 2,3,4,...), use this one:
=AVERAGE(INDEX(A:A,n+10*(ROW()-ROW($B$1))):INDEX(A:A,n-1+10*(ROW()-ROW($B$1)+1))
where you should change n to 2,3,4,...
I have an excel sheet as shown below. I need to get the top third/ next third items by sales count. Is there a way to get this done in Excel?
Item Count
1 100
2 90
3 80
4 60
5 55
6 50
7 45
8 35
9 25
Dividing into 3 buckets, so 540/3 = ~180 items in each –
Bucket 1 – Items 1 and 2 (Count = 190)
Bucket 2 – Items 3, 4 and 5 (Count = 195)
Bucket 3 - Items 6, 7, 8, 9 (Count = 155)
There are multiple ways to achieve this. Assuming that your Item and Count data are in columns A and B, then the shortest path is to use the following formula in cell C2:
=ROUND(3*SUM($B$2:$B2)/SUM($B$2:$B$10),0)
After entering that into C2, select that cell and drag down the right-bottom corner of the cell all the way to the last row. Note the $ sign that is "missing" on purpose before the second 2. That takes care of the auto-fill behavior needed when dragging down the corner.
If you are allowed to use a helper column, you can create a computationally more efficient method using following layout:
If you want to, you can hide column C. It contains cumulative values of the different sales counts. Cell C1 is set to 0, cell C2 contains the formula =$C1+$B2. Column D then approximates the buckets by using the formula =ROUND(3*$C2/$C$10,0) in cell D2, and then again dragging down the bottom-right corner. This might be the better approach if you have many rows on your sheet.
Note that both solutions yield the same results. The value in one or more buckets could become 0, which is not exactly right. That can be avoided using ROUNDUP in stead of ROUND, but since you have not indicated clearly where you want the boundaries of the buckets to fall exactly in different situations, I thought I leave that as an exercise to you :-).