Get count of cells in column where sum of those cells are less than a specified value - google-sheets

I have a spreadsheet where I am trying to get the count of cells in a column, where their sumproduct value reaches a specified number (I wrote comments on the spreadsheet that should make it clearer).
So far I have got some sort of formula, but it is returning me the total count of all cells in the range a specify? I cannot figure out how to do this, so any help would be much appreciated.
My formula:
=ArrayFormula(countif(sumif(SUMPRODUCT(AB13:AB,if($X$13:$X<>"",1/$X$13:$X,1)),"<="&AB13:AB167,AB13:AB167),"<="&abs(AB9)))

Here's my copy of your sheet. It's set to "anyone can edit".
https://docs.google.com/spreadsheets/d/1ebu7UNCVuG7DyC4kVGLiRr3AT4vyU2V_lwlnALQfGy4/edit?usp=sharing
This is the formula I came up with. It gets rid of the need for the row count column you have.
=ARRAYFORMULA(MATCH(F11,MMULT(N(ROW(F13:F)>=TRANSPOSE(ROW(F13:F))),IFERROR(F13:F/MMULT(N($F13:$H<>""),TRANSPOSE(COLUMN($F13:$H)^0)),0))))
It will be a little slow with very large sheets. You'd need a different solution if you were going to have more than a couple thousand rows.

Related

Find a way to increment formula in merged cells and blank cells

It's my first time posting here, I tried to look for something similar to what i am looking for but couldn't find anything, but if I just didn't look enough, I apologize.
My problem is as follows:
https://docs.google.com/spreadsheets/d/10yx-WO_SlOnFLNW83N8wucOrcexfLtt1TE2FDzTAQbc/edit#gid=799857548
I have a data table with information I receive from somebody. I then need to use that information to feel kind of individual product data table on another sheets, and add more to it.
Instead of copy everything of sheets one in sheets 2, I would like it to feel by itself.
I tried with =Cellsadress or =OFFSET and other stuff but couldn't manage to get what I want.
When i put every formula in the green table on sheets 2 and try to increment it by dragging down, the formula values increase by 25 approximately. but i want it to increase by only one, or find another way to show the information in the column of sheets 1 to reflect in different cell of sheets 2.
In my real document i have 100 of lines, so i cant do it manually like i could do with 4 lines.
Is there a way to do that?
If somebody have a solutions i would be gratefull
try this formula for C32 =INDIRECT("'Sheets 1'!F"&(int(row()/25)+2))
when you copy-paste this formula into cell C57 or C82, it will take values from 'Sheets 1'!F4 and 'Sheets 1'!F5, respectively

Count number of times values increase in range - Google Sheets

how are you? I'm just not sure what to do here, but I surely can use your help!
I have a series of values in a row range, such as in the following:
1000 2000 1500 2100 3200
I need to figure out a google sheets formula to put in the 6th cell of this row that counts the number of times the value of any cell is greater than the one to the left of it. In this example, my result should be 3.
Is there any way that this can be done? In Excel or Google Sheets, either is great to learn.
Thank you
You can also try the following formula
=COUNTIF(QUERY({{"";TRANSPOSE(B2:F2)},{TRANSPOSE(B2:F2);""}},
"select Col1-Col2 offset 1 label Col1-Col2 ''",0), "<0")
Assuming you have data in A2:E, place the following in F2:
=ArrayFormula(IF(A2:A="",,MMULT(IF(B2:E>A2:D,1,0),SEQUENCE(4,1,1,0))))
Since there are only four columns that might be greater than others (B:E), you can structure it this way. MMULT is hard to explain, but it essentially multiplies everything in each row of one matrix (range) by everything in another range and then adds them. SEQUENCE just forms a column of four 1's by which to multiply then add together everything in each row of the first range. Since anything times 1 is the original number, this just serves to to row-by-row addition.
This formula will process as many rows as have data in A2:E.
try in 7th column on row 2:
=ARRAYFORMULA(MMULT(IF(A2:E4<B2:F4, 1, 0), {1;1;1;1;1}^0))

How to format the first X rows based on sort order?

I have a google sheet that calculates a score for each row based on numeric values in the different columns. I then sort it by the calculated score, high to low. Now I want to conditionally format (bold) the first X rows in the sheet based on that sort order.
Does anyone have any suggestions on how to achieve that? I've been googling for hours now, but no joy.
Thanks!
It should be something like this:
=rows(A$1:A1)<=10
for first 10 rows

Using the same formula for each row in sheet

I want for every row in my sheet to calculate a score using a formula. So the same formula for each row. I tried this:
=ARRAYFORMULA(min((((C3:C100)/4)+((K3:K100)*4/10)+(M3:M100)+((N3:N100)/2.5)+((O3:O100)/5)+(R3:R100)+(T3:T100)+((P3:P100)/3)+(V3:V100))/23))
But it does calculate at all, for any row. (I am starting from row 3)
Why does it act like this? Any suggestions?
It's always best to provide us a link to your sheet, so we can see what you're trying to accomplish (or at least create a copy without sensitive data and share that).
If you want the same exact formula for each row, you will get the same exact result with your current formula. Also, do you mean to SUM the range values you have provided inside the formula? If so, you need to alter your formula to look like this:
=ARRAYFORMULA(min((((sum(C3:C100)/4)+(sum(K3:K100)*4/10)+sum(M3:M100)+(sum(N3:N100)/2.5)+(sum(O3:O100)/5)+sum(R3:R100)+sum(T3:T100)+(sum(P3:P100)/3)+SUM(V3:V100))/23)))
Please be more specific about exactly what you want the formula to calculate on each row. If it's on row 20, for example, do you still want rows 3-100 to be considered? Or just rows 20-100? WHAT data do you need to be considered on each row's formula, in other words?
Here's a sheet I created to try to understand what you want:
https://docs.google.com/spreadsheets/d/1GRdU6NLMWx2xPXDNp21VzYRQRj6cjNbL4RGVUV2x8Wk/edit?usp=sharing

How to average the last seven values in a column?

I am trying to find the average of the seven most recent entries in a row, as seen in
this
spreadsheet.
I found a few questions similar to mine, but I am still pretty confused on how the answers work. The questions similar to mine can be found on the left side of my spreadsheet.
I think that the formulas would work for me with a few simple adjustments of which values to use, but I can't seem to figure it out. I would really appreciate if someone could explain one of the existing answers or come up with another one that works.
The spreadsheet is updated daily, so I need something that would continue to work as more and more data is added to the column.
Try:
=round(AVERAGE(OFFSET(H1,MAX(ARRAYFORMULA(ROW(H:H)*--(H:H<>"")))-7,,7)))
here's working sample
Explanation
We are getting the last non empty row: MAX(ARRAYFORMULA(ROW(H:H)*--(H:H<>"")))
Then with offset formula we are getting the range of last 7 cells in a column.
And then just use AVERAGE.
More info
You may find more info about finding the last non empty row here:
Selecting the last value of a column
Another way is to use INDEX and MATCH. The first match finds the position of the last number in the range and takes 6 away from it: the second match finds the position of the last number in the range. Passing it through the INDEX function gives a reference that you can use to give a range of 7 cells for AVERAGE to work on.
=average(index(H:H,match(999,H:H)-6):index(H:H,match(999,H:H)))
So my answer is like your Link2
The big snag here is if you have a text cell in the range (like "Nothing") it is much more difficult to work out which cell to start from to get an average of 7 cells. I think I know how to do it in Excel using OFFSET but offset doesn't seem to work in the same way in Google Sheets.
However I can see there is a solution to this in your Link3 which should work for you if you change A:A to H:H and SUM to AVERAGE. I have tested it on the average of the last ten cells which includes a "Nothing" cell:
=ArrayFormula(AVERAGE(QUERY(SORT(H:H,ROW(H:H)*ISNUMBER(H:H),0),"select * limit 10")))
and it gives the correct answer 61.8.
The way array formulas work in general is that instead of passing a single value to a function you pass a whole range or array (a list of values) and the function processes them one by one. The above formula takes the whole column H:H and sorts it on the row numbers in descending order but those cells which don't contain a number give zero in the multiplication and are sorted to the bottom. Then the query takes the top (in my case) 10 cells and passes them to AVERAGE.
BTW this doesn't have to be declared as an array formula: this also works
=AVERAGE(QUERY(SORT(H:H,ROW(H:H)*ISNUMBER(H:H),0),"select * limit 10"))

Resources