Google Sheets array formula not working for negative numbers - google-sheets

I have used this formula so many times and cannot get it to work for values less than zero
Formula: =ArrayFormula(iferror(index(PayrollSummary!A:A,small(if(PayrollSummary!I:I<0,row(PayrollSummary!I:I)),row(4:4))),""))
I use this to find the text of one column based on the value of another. It is the if(PayrollSummary!I:I<0 that is not working, if I change it to less than 1 I get values from 0-1, but not the ones less than 0.
I have checked the formatting on the column, tried number, financial, custom number formats. I have put the PayrollSummary!I:I within VALUE() I have tried LTE(), it will not give be the negative numbers.

try:
=ARRAYFORMULA(IFERROR(INDEX(PayrollSummary!A:A, SMALL(
IF(PayrollSummary!I:I*1<0, ROW(PayrollSummary!I:I)), ROW(4:4))), ))

Related

Google sheets percentage of values where the difference between two columns in another sheet, is less than the value in a third column of the sheet

I'm on google sheets trying to find the percentage of values where the difference between two columns in another sheet, is less than the value in a third column of the sheet. I've tried a bunch of things but all come up with err0rs or parse error. Any help is appreciated.
This is what I came up with.
=COUNTIF((sum(Data!($E$2:$E$229):Data!($F$2:$F$229)),"<Data!$C$2:$C$229"))/count(Data!$C$2:$C$229)
then I make it a percentage value
Thanks for your help!
If possible, the simplest strategy would probably be something like this:
In the sheet with the two columns, calculate another column that is the difference of the first two. E.g.:
=A1-B1.
Then, write an if statement that checks whether that difference is less than the value in the third column. If it is, return 1, if it isn't return 0. E.g.:
=IF(C1<D1, 1, 0)
Finally, calculate the percentage of values that are less with a formula like this:
=SUM(if_column) / COUNTA(if_column) * 100
SUM returns the count of all cells whose difference is less than the third column and COUNTA returns the total number of non-blank cells.

What's going on with my max value operation in google sheets?

I'm doing a very simple max function to find the max between 2 cells, it works on the first few lines, but doesn't work the rest of the way down.
You'll see in the pic the max functions are in column R and only find the max between cells in column P and Q.
What you can't see is Column P is data input manually, while column Q references a different cell that contains a formula.
Why is this not working? thanks
The issue with your ranges is that the values in range Q1:Q are NOT numbers.
Reading the official page about the MAX function:
Each value argument must be a cell, a number, or a range containing numbers. Cells without numbers or ranges are ignored. Entering text values will cause MAX to return the #VALUE! error. To allow text values, use MAXA.
Because they are not numbers they are considered as 0.
So, when using =max(P2,Q2) the result appears realistic.
But not always.
Do test your values using =ISNUMBER()
You can correct the formulas by formatting values as numbers.
Just using a value alone didn't work for me. Wrapping my range in an arrayformula with a nested value formula worked. For example:
=max(ArrayFormula((value($R2:$R))))
This is probably because my entire column is calculated using formulas. I had to apply the value formula to the entire array.

Excel/Sheets Consecutive Count Based on Two Conditions (function?)

I have a Google Sheet, and I'm trying to see if it's possible to get a consecutive count outputted in a third column based on the values of two other columns.
My columns are:
Column A: Will have a handful of text values that are "grouped" together. Likely around 30 of the same value, until it changes to another value. In the image above, these are text1, and text2.
Column B: Will have one of 3 values assigned to each value in column A. In the image above, these are id1, id2, id3.
Column C: Will output a consecutive count based on the values of the first two columns. My hope is that if there are multiple ID1,ID2 in consecutive order, they'll repeat that first +1 value; while ID3 is always plus 1 to the count. This is what I am trying to show in column C in the layout image above.
I've hit a wall with trying to accomplish this with various COUNTIF iterations.
Thanks for any help, or any better ideas to accomplish something similar.
(I'm hoping for a formula, but open to being pointed into a direction for a script if that's the only way).
You can try following formula:
=IF(A2=A1;IF(OR(B2="id3";B2<>B1);C1+1;C1);1)
It is also possible to do this as an array formula. I used offset ranges for column B in the first Countifs to check for a change in value but this made it a little awkward to get equal-sized arrays:
=ArrayFormula(if(A2:A="","",
countifs({"";B2:B}<>{B2:B;""},true,{A2:A;""},A2:A,row(A:A),"<"&row(A2:A),{B2:B;""},"<>id3")+
countifs(A2:A,A2:A,row(A2:A),"<="&row(A2:A),B2:B,"=id3")
))

Extract Values from Cells > Sum the Values > Multiply the Values

I have two sheets in my Google spreadsheet, "input" and "output".
On my "input" sheet I have multiple values,
which always have a certain letter in front of them.
On the other sheet "output" I want to add all values together for each letter
and then be able to multiply this result with another value.
The values sometimes are whole numbers, other times they hav decimal places.
I tried the following functions to extract only the number without the letter,
but then the extracted value was not a number that I could continue to use for other math functions such as multiplications.
=REGEXEXTRACT(XX;"[0-9]+")
=REGEXEXTRACT(XX;"[0-9]*\.[0-9]+")
=REGEXEXTRACT(XX; "\d+")
=SUM(SPLIT(XX;CONCATENATE(SPLIT(XX;".0123456789"))))^
If I tried to use "=VALUE(XX)" I got a weird number.
Also this formulars are only for one cell,
but I want the formula to work on the whole "input" sheet.
Therefor it must be used in combination with something like
=SUMIF('input'!A:Z; "XXXX"; 'input'!A:Z)
...at least this is my best guess.
I linked a sample sheet below, can you help me out guys?
Many thanks in advance!
Google Spreadsheet Test
For getting the sum of the cells which have letter "E" at the beginning, try the following formula:
=sum(arrayformula(iferror(regexextract(input!A1:H100,"E ([\d.+]*)")*1)))

Get the average of two multiplied columns in one cell, without an extra column

So I've been searching and experimenting with formulas I've found across the internet that are supposed to to what I need but definitely do not.
What I need is the average of the 'total' column in this, which would be 13, without actually having to have a 'total' column. In my head the formula would be something like, =AVERAGE(A1*B1,A2*B2,A3*B3)
but without having to manually enter each set of cells.
Instead what seems to be happening when I use the formulas I've found, is that it multiplies the total sums of each column, and then averages that, which results in 39.
I know a simple solution would be to just leave that 'total' column there, and then just average that, but I don't want to add an unnecessary column when it seems like there should be a way to multiply each set of cells and then sum that and get the average of those in one formula.
Formulas I've tried so far:
=AVERAGE(SUMPRODUCT(A1:A,B1:B)) <---results in 39
=ArrayFormula(AVERAGE(A1:A*B1:B)) <---results in 39.75
=SUMPRODUCT(A1:A,B1:B)/COUNT(A1:A) <---results in 39.75
=ARRAYFORMULA(AVERAGE(MULTIPLY(A1:A,B1:B),COUNT(A1:A))) <---results in 10.5???
Here you go:
=SUM(ARRAYFORMULA(A1:A*B1:B))/counta(A1:A)

Resources