Remove Unused Cells in Arrayformula - google-sheets

I'm usually pretty good about modifying the arrayformula so that cells aren't displaying values when there is no data adjacent to it. But, with these money values, I can't seem to change it to work. How can the arrayformula be changed so that $0.00 doesn't appear all the way down the column for data that is not yet present?
Here's the spreadsheet to edit. Arrayformula is in yellow highlighted cell.
Thanks for your help!

One solution is you can expand the computation to:
=ARRAYFORMULA(IFERROR(1/(1/(DMAX(TRANSPOSE(A3:G), SEQUENCE(ROWS(A3:G)), {IF(,,);IF(,,)}))),""))
The formula will originally return an error for zero result, but because of the IFERROR it will be replaced by space.

Related

How can I avoid highlighting empty cells when formatting date ranges?

I need to highlight past due items, but Google sheets is also highlighting all of the blank cells in that respective column, which I don't want. (Is it because Google sheets is assigning blank cells a value of zero?) Anyway, my custom formula is as such:
=$A1:$A<=today()
I've tried various combinations of formulas similar to this one:
=AND(NOT(ISBLANK($A1:$A),$A1:$A<=today())
but my syntax is off somewhere.
Any help would be greatly appreciated.
your formula is just a bit spotty at one of the closing brackets.
=AND(NOT(ISBLANK($A1:$A)),$A1:$A<=today())
OR
=(A:A<=today())*(A:A<>"")

ARRAYFORMULA does not increase cell as it expands

I'm trying to get an ARRAYFORMULA to subtract the current cell from the previous one,
but it appears that if I write
=ARRAYFORMULA((A3:A)-(A2))
The formula does not increase of one cell as it expands.
here's an example of what I get
https://docs.google.com/spreadsheets/d/1ci4kiNCgjBZK0Ue218IRIk5t8tSmElF5EgbIxb1_Q9w/edit?usp=sharing
it's clear that it keeps referencing A2 (but I'm not using $A$2 in the formula)
if I wouldn't use ARRAYFORMULA I would simply use
=SUM(A3-A2)
Can anyone suggest me a solution?
Your sample spreadsheet is still "View only"; so neither I nor anyone else can directly leave our solutions. However, place the following formula in D1:
=ArrayFormula({"Difference"; IF(A2:A="",,IFERROR(A2:A-OFFSET(A2:A,-1,0)))})
This will create the header (which you can change within the formula itself as you like) and all results.
(Adjusting to the location in your actual spreadsheet, as indicated in your post, this would be =ArrayFormula({"Difference";IF(L7:L="",,IFERROR(L7:L-OFFSET(L7:L,-1,0)))}).)
Couple Comments
You should accept Erik Tyler's answer as he put in more work and helped you present your problem more clearly. However these formulas allow for some more flexibility if you want any values below the rows (which now that I think about it doesn't make a lot of sense based on having a dynamic array flowing down, but conceptually maybe someone will find it useful).
Simple Formula will require one cell below your range to be blank:
=iferror(filter(filter(N(A2:A),A2:A<>"")-N(A1:A),A1:A<>""),"")
Complex Formula will allow values directly below (which I again admit seems nonsensical considering the whole point of this is a dynamic expansion down rows...)
=Filter(filter(filter(N(A2:A),A2:A<>"")-N(A1:A),A1:A<>""),ISNUMBER(filter(filter(N(A2:A),A2:A<>"")-N(A1:A),A1:A<>"")))
I gave a demo on your page.

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

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.

Sum of cells containing a formula in google sheets

I want the sum of values in a column. However I wish to ignore cells which do not contain a formula. I tried
=SUMIF(A1:A10, ISFORMULA(A1:A10))
But that did not work
if its a small range you can do:
=SUM(FILTER(A1:A10, {ISFORMULA(A1); ISFORMULA(A2); ISFORMULA(A3);
ISFORMULA(A4); ISFORMULA(A5); ISFORMULA(A6);
ISFORMULA(A7); ISFORMULA(A8); ISFORMULA(A9); ISFORMULA(A10)})
This way might work for you.
I added a column with the following formula, which unfortunately also doesn't work as an arrayformula. But if you put this at the top of your column, beside the one you want to sum, and double click the "drag down" blue square on the bottom right corner of the cell, it will fill all the way down, provided you have no blank rows. Dragging down also works obviously.
=IFNA(FORMULATEXT(A1),0)
This creates a column of zeroes and text formulas, which you can use as a filter for your SUMIF formula, as follows: (assumes data column is A1:A30, helper column is B1:B30. SUMIF is in C1)
=SUMIF(B1:B30,"=0",A1:A30)
Let me know if this is useful, or not.

Stop google array formula from expanding sheet to 50,000 rows

I've got an array formula which I've managed to put together as this:
=ARRAYFORMULA(if(row(B:B)=1,"Status",(if(D:D="","",IF(D:D<today(),CONCAT("Overdue by ",(TODAY()-D:D) & " days"),IF(D:D<TODAY()+30,CONCAT("Due in ",(TODAY()-D:D) & " days"),if(D:D>today(),"Not Due","")))))))
For some reason it expands the sheet much larger than I need it with blank cells. I only need it to a max of 500. Any ideas how I'd stop this from happening?
In extremis you might wrap your formula in ARRAY_CONSTRAIN and predefine the maximum number of rows and columns:
=array_constrain(ARRAYFORMULA(if(row(B:B)=1,"Status",(if(D:D="","",IF(D:D<today(),CONCAT("Overdue by ",(TODAY()-D:D) & " days"),IF(D:D<TODAY()+30,CONCAT("Due in ",(TODAY()-D:D) & " days"),if(D:D>today(),"Not Due",""))))))),500,1)
Late with the answer, but I've noticed that ArrayFormula starts expanding sheet only if the formula is not in the same row as the first cell you're targeting, so in your case B:B - ArrayFormula should be placed in first row, for B2:B - it should be placed in the second row.
Note: this behaviour only applies to to ArrayFormulas that store nested functions such as IF statements.
Thank you for the pointers in this thread. I had an arrayformula that started:
=arrayformula(if(A3:A="","",[do stuff()]))
The formula created 50,000 rows which slowed everything to a crawl.
I edited it to constrain the array to 996 rows thusly:
=arrayformula(if(A3:A999="","",[do stuff()]))
All was well and the sheet was fast as lightning again
You probably have that formula in more than one cell, and it seems it should only be in the first row of whichever column you want it to be in.

Resources