Array formula for countifs to propagate down the rows (only for rows with data in column A) - google-sheets

I am new to google app sheet formulas.
In the image attached i have highlighted the formula, it works.
The formula i am using is =COUNTIFS(D4:S4,"y",D3:S3,"Personal")
Now i want to propagate this using ARRAYFORMULA for rows 5 and 6.
I tried with the below formula
=ArrayFormula(if(len(A2:A),COUNTIFS(D4:S,"y",D3:S3,"Personal"))
--Update
After adding the formula provided by Matt i am getting count mismatch for one row
--Update #2
As suggested by Eric, i found a space in the Header row

Unfortunately, it's not quite that straightforward to populate a COUNTIFS that reads sideways like that in the down direction. The common way to do this is with a function called MMULT() which does "matrix multiplication" but is very good for adding or counting across a 2d range like that. In your case because it's dates going sideways, i'm going to assume that the sheet keeps growing to the right? All the way across indefinitely?
You might try this in cell B4:
=ARRAYFORMULA(IF(A4:A="",,MMULT(N(OFFSET(D4,,,9^9,9^9)="Y"),TRANSPOSE(N(D3:3="Personal")))))
You can check out this MMULT() demo sheet I made a while back.

Related

Refer to itself in ARRAYFORMULA

I am just wondering whether it is possible to achieve what I need to achieve, but using an ARRAYFORMULA.
I have a simple setup where in column B I show the value, which is present in the last previous filled in row in column A
Here is an example.
So, the questios is: is it possible to achieve the same, but with ARRAYFORMULA(s), so that in case a new row is incerted, one does not need to drag formula to fill in the new row, but the formula would be added automatically. All my attempts ended up with the circular reference problem.
This is tradtionally done with a vlookup of row numbers into a filtered array of the values. It would look like this in row 4 of your sample sheet:
=ARRAYFORMULA(VLOOKUP(ROW(A4:A),FILTER({ROW(A4:A),A4:A},A4:A<>""),2,TRUE))

Apply same formula to every cell

I have a sheet with several numbers, which I want to convert to percentage. These are scores imported from a form, where the maximum score is 5.
According to the bellow image, the cell B2, I applied a basic formula =(3/5)*100% to convert three to 60%.
In order to avoid copy and paste the same formula into all cells, is there any formula to find all the cells and apply its value, divide per 5 and multiple per 100%? I thought something similar to Javascript such as (this/5)*100%.
https://docs.google.com/spreadsheets/d/1ZtqJaXy1pHkjk1sywGfSodo0FcOoLlkou79cZBk-jmU/edit?usp=sharing
you could treat it as array and on Sheet2 use:
=ARRAYFORMULA(IF(Sheet1!B2:AA="";;(Sheet1!B2:AA/5)*100%))
demo sheet
I've also looked for a solution to this for some time.
I don't think it's possible as a cell can only hold one value and the moment you try to change that value, it will delete the value.
Your best bet is to create a different table on the same sheet that references the specified values, then copy and paste the results (values only).
Just create a second Sheet, then in cell B2 of Sheet2 use the formula =Sheet1!B2/5*100%.
Then copy the formula to all cells of Sheet2.

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.

How to use arrayformula to dynamically join strings in google spreadsheet?

I use Arrayformula() to make my reports dynamic and easier to edit. For example, if I have a Column A with a list o number o blue balls in a set and a Column B with a list red balls in a set, on the cell C1 I can write =ArrayFormula(add(A1:A,B1:B)) and in the Column C will have the total of balls in each set. It would be exactly the same as writing =A1+B1 in cell C1 and dragging the formula down to the last row. Arrayformula() has some benefits, because it will work if some adds or removes rows from the sheet and also it makes the reports way more organized and easier to edit.
Since I´ve discovered arrayformula(), my life has changed, because of the fact that googleSheets expands the formula to other cells. It does not work every time, but the idea of expanding to other cells seems to be possible some way or another, here is a good example of a problem that was not resolved by arrayformula(), but has the same idea.
Keeping that idea in mind, imagine that on Column A there is a list of First Names and on Column B there is a list of Last names. On Column C I want to join this two string using a simples space. The way to do that would be in the cell C1 write =join(" ",A1,B1) and then drag down this formula. This method method however is prone to error since people can add and remove rows, deleting my formula. I want to use a formula that I can write in one single cell and it expands to other cells. I´ve tried =arrayformula(join(" ",A1:A,B1:B)), but it does not work.
Is that a way to do that using =arrayformula() or other native function?
I know I could write a script or custom formula to do that, but this is not my goal here.
I think this formula should work:
=arrayformula(A1:A&" "&B1:B)
In case you want to use a delimiter, you can do the following to have a clean result even though, A or B is not present in some cases:
ARRAYFORMULA(ifna(ifs(isblank(A1:A),,ISBLANK(B1:B),A1:A),A1:A&" - "&B1:B))

Increment row, not column of spreadsheet

I am working on a spreadsheet that tracks my running mileage. I've got all my miles in one column, but I want to be able to create a "Calendar View" of sorts, so I can track my miles on Mondays, Tuesdays, etc.
To do this, I am using: =Mileage!C13 for cell b2.
For cell B3, I want: =Mileage!C14.
Obviously, I will be using 7 columns for the calendar, but when I try to create a series in the row, it increases the column (instead of C14, it gives D13).
Also, I tried doing a series in the column instead, and increasing by 7 with no luck.
B2: =Mileage!C13. B3=Mileage!C20. If I select both cells and try to create a series, it gives me =Mileage!C14 instead of =Mileage!C27.
I hope this makes sense... any tips, or am I going about this completely wrong? Thanks!
You can reproduce the first 7 cells in a row fairly easily with the TRANSPOSE function:
=TRANSPOSE(Mileage!C13:C19)
However this still doesn't address the issue of being able to easily fill the formula down. Using OFFSET, we can rewrite the above formula to:
=TRANSPOSE(OFFSET(Mileage!C$13,0,0,7,1))
and then use the ROW function and a bit of maths in the second argument:
=TRANSPOSE(OFFSET(Mileage!C$13,(ROW(A1)-1)*7,0,7,1))
This formula you should now be able to fill/drag down successfully.

Resources