Average time durations in google form populated google sheet - google-sheets

I have a google sheet that is auto populated from a google form. There is a column with time durations:
When I try to average these durations I get the divide by zero error. I tried changing the cell format, but nothing works. And in fact, it wont change at all no matter what format I choose. I think the format is locked based on the form that is populating the sheet.
Any help on getting the average in a cell below the column?

Please try a formula of this kind:
=sum(ArrayFormula(1*(A1:A15)))/counta(A1:A15)
with formatting to suit.

The problem is you are getting values as text.
=ArrayFormula(AVERAGEIF(A1:A18*1,">0"))
*1 converts text into a number
condition ">0" to skip empty cells, converted to 0.
format the result as duration.

Related

Exact same formula producing two different results depending on cell in google sheets

I'm making a calendar heat map of my org's sessions per day. There might be easier ways to do it, but I have one sheet for a calendar, another listing every single session by day, and the heat map sheet that looks at the equivalent calendar cell and counts how many sessions match that date. Conditional formatting changes the colour of the date cell depending on the number. Screenshot of sheet setup. (sorry, can't imbed images)
Each cell on my heat map matches a cell on the calendar sheet, so each heat map cell contains:
=countif(Sessions!$A:$A,'Calendar 2021'!B5)
with the cell address changing for each date.
It all looked good until one date cell returned the wrong count for that date. When I checked the formula for that date, I found that it did return the right count - when I copied it to a different cell.
It's the exact same formula in each cell :
=countif(Sessions!$A:$A,'Calendar 2021'!C23)
but in columns A-L, it returns '3', and after column M it returns '4' (the correct result).
screenshot of different results
Any idea what's causing that?
If it's useful to have a look yourself, here's a version with the same problem (stripped of all data but the dates): https://docs.google.com/spreadsheets/d/16xP_a_KgeIoqomdsk3kMUDuV2GyIVMoNoOusvfWJdNU/edit?usp=sharing
You have different formatting applied to the various cells: none of which are correct for your use, by the way.
In the cells producing a result of 3, you have formatting set to "d". This means you're requesting that the format show the day of the week instead of the underlying number (meaning that the only possible returns for this formatting are the numbers 1 - 7). Since your underlying correct number is 4, the d formatting assumes that 4 is a raw date. The date-time origin in Sheets is December 30, 1899, which corresponds to the number 0. So 4 would translate to January 3, 1900. And the day of the week (d) of that date was a Tuesday, which in Sheets, is day 3 of the week counting from Sunday ... hence your formatted return of 3.
In the cells returning 4, it is only a happy accident that they are; because you've got the formatting for those set to return a date-time. As it so happens, the raw number 4 is the same as the 4th day from the origin date in Sheets; so you happen to be getting a formatted return of 4.
You should be selecting the entire range A:R in your heat map sheet and setting the formatting to simply '0', which means "the original raw number." Setting the formatting this way will not affect text, only numbers.
I should note that your formatting and data types in your sample sheet are all over the place. Some of your numbers are generated by formula. Some are raw dates. So when you set the whole thing to formatting 0, many of your cells are going to show numbers in the 40000 range, corresponding to the number of elapsed days for the underlying date as marked from December 30, 1899. You'll need to be sure that every applicable cell in your heat map sheet contains a formula that returns the COUNTIF, not dates.

How to make Google Sheet arrayformula work with date functions

I have a column of dates with the format "yyyy-mm-dd". And I want to do summary statistics by month -- using native formulas.
When I put arrayformula around month(...)>month(...), I get the error
Result was not expanded automatically, please insert more rows (1).
Why is that? And how do I get around that?
Example sheet. Formula in B4.
=arrayformula(month(B4:B)>month(B3:B))
Note: I don't know the number of rows ahead of time -- it is expected to update from time to time.
Firstly, erase your formula, it is trying to automatically expand the sheet and the sheet already has over 50,000 rows.
Next delete 48,000 rows or so.
Next put this formula in cell B4:
=arrayformula(month(B4:B)>month(arrayconstrain(B3:B,rows(B4:B),1)))
That will prevent the formula from auto-expanding the sheet.
That should work, though I think you're going to realize you don't like what happens when the year changes. I believe this to be an xyProblem.
=arrayformula(if(isblank(B4:B),,month(B5:B)>month(B4:B)))
works.
It seems it is always better to include an isblank() wrap to avoid indefinite expansion of the sheet.

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.

How do I conditionally format if value extracted is > number value?

I have a use case where I need to conditionally format a cell if the extracted value from this formula is greater than 5.
=trim(MID(C3:AZ,FIND("-",C3:AZ)+1,FIND("pts",C3:AZ)-FIND("-",C3:AZ)-1))>5
When I lock the cell references, I still don't get any conditional formatting, even though it accepts the formula:
=trim(MID($C$3:$AZ,FIND("-",$C$3:$AZ)+1,FIND("pts",$C$3:$AZ)-FIND("-",$C$3:$AZ)-1))>5
When I do the formula referencing a single cell, I get the expected output:
I've made an example Google Sheet for reference, if you'd like to take a look at the sample dataset.
Any help/advice you all could provide would be greatly appreciated.
Thanks!
Try this formula. The way conditional formatting works is if the range for conditional formatting starts on A3, then you can put that one cell as the checking value, and the spreadsheet is smart enough to then check each cell in the range separately. I put a value around it as well since "trim" makes it a text instead of a number.
=value(trim(MID(A3,FIND("-",A3)+1,FIND("pts",A3)-FIND("-",A3)-1)))>5

Exporting values of unchecked items in Google Forms checklist

Using Google Forms checkboxes to collect survey responses into a Sheets doc, I find that I can only get the values of checked lines to fill the spreadsheet.
I'm trying to get the unchecked CheckBox values to fill a different cell in the spreadsheet as well, has anyone found out a way to do this?
I'd appreciate any help!
I have a way with spreadsheet formulas.
The drawbacks are the necessities of
manual input of all possible options
copying and pasting a formula for each response (can be done in advance, but if not enough formulas are pasted for the number of responses, the sheet will break)
An ideal solution would automatically detect all possible responses, and could theoretically accept an infinite number of responses without breaking and needing maintenance.
With that said, he's an example of what I suggest:
Google Sheet
Google Form
All possible options on the form must be typed into cells A2:A
cells B2:B show comma+spaces if the corresponding cell in A2:A is not blank, with =arrayformula(if(isblank(A2:A),"",", ")). These commas and spaces are needed later in a concatenate().
Raw data from the Form Responses spreadsheet was brought into D2:E with =arrayformula('Form Responses 1'!A2:B)
G2:G holds the important formulas. They must be copied and pasted to each individual cell for each row.
First, all possible responses in $A$2:$B are filtered based on if the cell in column A can be found in the text in column E.
=filter($A$2:$B,arrayformula(iserror(search($A$2:$A,E2))))
Next, some error catching. I added an iferror() to catch a "N/A, no results found in filter evaluation", and an if(isblank(),"",) to catch if no timestamp is in column D meaning no response was recorded in this row.
=if(isblank(D2),"",iferror(filter($A$2:$B,arrayformula(iserror(search($A$2:$A,E2)))),""))
Finally, do a concatenate() to pull the values and the comma+spaces all into one string inside one cell.
=concatenate(if(isblank(D2),"",iferror(filter($A$2:$B,arrayformula(iserror(search($A$2:$A,E2)))),"")))
Oh, and if you don't like the comma+space being the last characters in the string, in J2:J I did a =arrayformula(iferror(left(H2:H,len(H2:H)-2),"")) which cuts off the last 2 characters of the string in column H.
If I come up with a better solution, I'll let you know. It's an interesting puzzle to solve.

Resources