Array_Constrain error even after I remove it - google-sheets

I have a sheet with several ARRAYFORMULA(IF....) formulas. I think it was adding 1000s of extra empty rows to my sheet, so I wrapped them in ARRAY_CONSTRAIN(ARRAYFORMULA(IF...)),300,1
For some instances I get the error: "Wrong number of arguments to ARRAY_CONSTRAIN. Expected 3 arguments, but got 1 arguments."
In an effort to troubleshoot, I removed the ARRAY_CONSTRAIN completely, but I still get the same error! I copied the formula to a notepad, deleted the cell contents, and pasted it back in without AC, and STILL the same error. Any ideas why?
Here's a formula where AC works:
=Array_Constrain(ArrayFormula(IF($B$4:$B$250="",,
IMPORTRANGE($F$4,"Summary!N4:N250")+IMPORTRANGE($F$5,"Summary!J4:J250"))),300,1)
And one where it doesn't:
=Array_Constrain(ArrayFormula(IF($AA$4:$AA$250="",,
IMPORTRANGE($F$4,"Summary!AA4:AA250")+IMPORTRANGE($F$5,"Summary!W4:W250"))),300,1)
I've double-triple-quadruple checked my parenthesis and all seems fine.

Problem solved. The first IF statement was checking to see whether a reference cell was blank - IF($AA$4:$AA$250="",, - and that reference cell's AC formula did have a parenthesis out of place. So the legit error in AA4:AA250 was being passed on.
Sorry for the false alarm - I was super tired when I posted and should have taken another stab with a fresh brain first.

Related

Why is it faster in Google Sheets to split this formula into two steps?

Edit: I initially diagnosed this problem totally wrong, so the question is entirely rewritten to reflect new understanding.
The problem can be reproduced using a Google spreadsheet with one sheet that contains one header row and a significant number of additional rows (let’s say 5,000).
I wanted column A to increment by 1, starting with A2, as long as the adjacent cell in B was not blank. I used this formula in A1:
={"SKU"; arrayformula(if($B2:$B="","",text(row($A2:$A),"000000")))}
This formula worked but caused extremely significant lag.
In one of my attempts to resolve the issue, I added a helper column before column A and split my formula into two formulas to see which function was causing the lag:
Cell A1: ={"SKU (helper)"; arrayformula(if($C2:$C="","",row($A2:$A)))}
Cell B1: ={"SKU"; arrayformula(if($C2:$C="","",text($A2:$A,"000000")))}
To my surprise, the answer was neither. The lag was completely eliminated. What is the reason? And is it possible to eliminate the lag without the need for a helper column?
use:
={"SKU"; SEQUENCE(ROWS(A:A)-5344; 1; 5344)}
update:
={"SKU"; INDEX(TEXT(SEQUENCE(COUNTA(B2:B)), "000000"))}
if you have empty cells in between use:
=LAMBDA(x, {"SKU"; INDEX(IF(x="",,
TEXT(COUNTIFS(x, "<>", ROW(x), "<="&ROW(x)), "000000")))})
(B2:INDEX(B:B, MAX((B:B<>"")*ROW(B:B))))

Sumifs #ref error in google sheet - unexplainable

I have this very strange error which makes no sense to me.
I am using below formula to sum up sales values based on 2 criteria (one being month and the other one category)
=sumifs(Sales!$S:$S,Sales!$H:$H,D3,Sales!$Q:$Q,$A$12)
This formula works absolutely fine if I set cell D3 to 52020 (i.e. sum up all sales for may) - however, if I change the value to 62020 I am getting a ref error (same if I enter the value directly into the formula rather than using a cell). I tried other values and it looks like that only 62020 produces an error.
There are sales with 62020. In any case, this makes absolutely no sense to me especially given the error seems to come due to a Criteria not a range/ref.
I wonder if this is a bug (but probably I am missing something). Any ideas?
could be that for some reason your sheets converts it to date
62020 = 10/19/2069
try:
=INDEX(SUMIFS(Sales!S:S, Sales!H:H*1, D3*1, Sales!Q:Q, A12))

Inexperienced programmer requesting assistance in finding the error in a Google Sheets formula

Google Sheets tells me that there is a formula parse error for the following and I can't seem to find my mistake.
I have little programming experience but I want to make a fairly simple invoice form for the business I work in. I've written the following formula in a line total:
=IF(B28="Rabais", if(REGEXMATCH(I28,%),((sum(J19:J27)*I28)*-1), (I28*-1)), if(H28=0, I28, (H28*I28)))
I need that line total to change according to the following rules:
If the value "Rabais" is selected in the dropdown in cell B28, and if cell I28 contains a percentage, then the formula returns the negative of that percentage of the sum of the values of cells J19 to J27.
If the first criteria is true and the value of I28 isn't a percentage, then the formula returns the negative of the value of I28.
If the first criteria is false, then the formula checks if H28 is empty, and if so it returns the value of I28
If both If statements return false, then the formula returns the value of H28 times the value of I28.
I thought I had written everything properly, but obviously, I made a mistake somewhere and I can't seem to find it so I would appreciate a fresh set of eyes pointing it out.
this is how you do it:
=IF(B28="Rabais",
IF(REGEXMATCH(TO_TEXT(I28), "%"), (SUM(J19:J27)*I28)*-1, I28*-1),
IF(H28=0, I28, H28*I28))

Why INDIRECT function returns a 1?

I'm trying to return a count of names from another sheet (it's a list of names in Column A and I want to pull the # of individual names into a cell in another sheet). I have many sheets with varying lists of names. I'm using the COUNTA(INDIRECT function, but I keep getting "1" as the result.
=COUNTA(INDIRECT("'"&A2&"'!A:A))")
Can anyone help?
You're nearly there, just have to move the last quote inside the brackets and remove the extra bracket.
=COUNTA(INDIRECT("'"&A2&"'!A:A"))
to account for errors such as "nothing to count" you will need:
=COUNTA(IFERROR(INDIRECT("'"&A2&"'!A:A")))
and btw that was the reason why you were getting 1 from your formula attempt because COUNTA counted the error.

Selecting $M:$M and $N:$N returns "Array arguments to COUNTIFS are a different size"

I've simplified the code below for readability, after verifying that the other parts of the code do work. When I select a specific range, it works, but selecting the entirety of the M and N columns said that there are different array sizes.
I've checked the range, and both have their last cells at the same mark, so I'm not sure what the issue may be.
Please let me know if there's anything that is sticking out to you :)
=countifs("New Leads!"$M:$M), NameCell,"New Leads"!$N:$N),Value)
this is the correct syntax:
=COUNTIFS('New Leads'!M1:M, "NameCell", 'New Leads'!N1:N, 1)

Resources