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
Related
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’m wondering if someone can tell me how to count the number of duplicates that occur between 2 rows in excel? I’ve read lots of posts about counting duplicates in general, but it’s not quite what I’m looking for.
In the below example, I want to indicate how many numbers are repeated from the previous row. For example, Row 1 has 3 numbers repeating from Row 2. Row 2 has 1 number repeating from Row 3. Row 3 has 2 numbers repeating from Row 4. I don’t need to know what numbers or how many times each number was repeated, I just need to know how many occurrences of duplicates there are. Each number would be in its own cell. Is this even possible?
Row 1> 20 22 40 41 42 47
Row 2> 3 37 40 41 47 49
Row 3> 1 2 3 4 5 6
Row 4> 2 5 17 20 25 30
Use COUNTIF() wrapped in a SUM() as an array formula:
=SUM(COUNTIF(A2:F2,A1:F1))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly Excel will put {} around the formula.
Put the formula in the first desired output cell, Hit Ctrl-Shift-Enter. Then copy down.
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.
Say I have a column with values:
23
24
25
66
67
84
81
85
I want to divide this into N groups, say N right now is 4.
23,1
24,1
25,2
66,2
67,3
84,3
81,4
85,4
I actually need to divide around 30k sorted values into groups 1 to 99; each with equal number of elements.
Any quick way to do this in Excel?
With data in column A, in B1 enter:
=A1 & "," & ROUNDUP(ROW()/(COUNT(A:A)/4),0)
and copy down. For example:
.
Change the 4 in the formula to vary the number of groups.
I use this trick for equal data bucketing. Suppose you have data in A1:A8 range. Put this formula in B1:
=MAX( ROUNDUP( PERCENTRANK($A$1:$A$8, A1) *4, 0),1)
Fill down the formula all across B column and you are done. The formula divides the range into 4 equal buckets and it returns the bucket number which the cell A1 falls into. The first bucket contains the lowest 25% of values.
Adjust the number of buckets according to thy wish:
=MAX(ROUNDUP(PERCENTRANK([Range],[OneCellOfTheRange]) *[NumberOfBuckets],0),1)
The number of observation in each bucket will be equal or almost equal. For example if you have a 100 observations and you want to split it into 3 buckets then the buckets will contain 33, 33, 34 observations. So almost equal. You do not have to worry about that - the formula works that out for you.
if this is in column A
row 1
row 2
row 3
row 4
row 5
place formula in column B
=MOD(ROW(); 4)+1
this result in
row 1, 2
row 2, 3
row 3, 4
row 4, 1
row 2, 2
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 :-).