How to use AVERAGEIF in Google Sheets, only addressing columns with a specific text - google-sheets

In Google Sheets, I'm trying to use AVERAGEIF to calculate an average of only some of the columns in another table.
The columns to be included in the average are marked by some text in a specific cell (e.g. the first or last row of that column).
Some columns are to be included in several averages, so the text in the top\bottom row would include several words (effectively meaning I'll need some sort of substring check such as FIND).
I've tried using AVERAGEIF() in conjuction with FIND() but couldn't get this to work.
Any ideas?
Here is an example of how the data sheet looks like, and how I would expect it to work

You can use following formula:
=ARRAYFORMULA(AVERAGE(IF(ISNUMBER(SEARCH(D2,A2:A9)),B2:B9,"")))
Edit:
For table mentioned in comment you must change ranges:
=ARRAYFORMULA(AVERAGE(IF(ISNUMBER(SEARCH(E2,$A$1:$C$1)),$A$2:$C$4,"")))

You can use a query
=AVERAGE(QUERY(TRANSPOSE($A$1:$D),"where Col1 contains '"&D1&"'"))
Functions used:
AVERAGE
QUERY
TRANSPOSE

Related

Google sheets: How to write a formula that performs a sum from column_x until previous column and apply it to the rest of the columns

I have these two columns:
For the next columns I would to apply this formula:
SUM[all_previous_columns]
I would like to write it once for the third column and apply it for the rest of the columns.
Any idea how to do this?
You mean this?
You should use absolute addressing to first column in the range you want to sum and relative addressing to last column. Then you can drag your formula right as far as you want.
As it just doubles each time, you could also write it as an array formula:
=ArrayFormula((A1+B1)*2^(column(C1:1)-3))

Formula for looking up and filtering data from a sheet

I want to do a complex formula using google sheets:
I have a list of place that will be visited by different people.
Some places are not to be visited, marked with /
Some places need to be assigned, marked with ?
Wanted outcome:
A list of cells that changes every day automatic.
An overview of who is going where that day and what needs to be assigned.
So I need a formula that can select a row based on today() and then filter out Persons in that row. Then for each person, another formula that looks up the first row in the table and puts duplicates together.
Example:
Wanted outcome:
Link to excel file, but it needs to work in google sheets too: xlsx
My solution is not the most elegant but it does the job.
First I build a column with date and unique persons or ? in this column:
=unique(sort(transpose(index(A1:H10,match(today(),A1:A10,0)))))
Then I find Places corresponding to these persons (I use filter function for it and then I use textjoin to keep them in single cell).
The formula is copied down as filter function does not accept a range and arrayformula as a filtering criterium.
My solution is available here:
https://docs.google.com/spreadsheets/d/1GTy_UaFP8LbA8OLnEhT_R_twpDCIWCuvQfBAigqtbR0/copy

Highlight duplicates based on first name and last name

There are plenty of tutorials on how to conditionally format duplicates in a column, but how can I do this across two key columns without creating a third 'combo' column?
Edit: This formula gets me close:
=countifs(A:A,A1, B:B, B1)>1
But it only applies the formatting to column A when using A1:B2501 as the range
Using my formula
=countifs(A:A,A1, B:B, B1)>1
works as long as I create two rules, one for each column

[google spreadsheets]Joining Multiply Arrays in one formula

I am long looking for solution to a problem that states as this:
I have 3 different ranges in my spreadsheet (lets say they are on different sheets) and I want to join them all on the 4th sheet as one array (like one under another).
And here is my question how can I dot it? I want to then use filter on the given range to make all 3 ranges one sorted range and I want it to enlarge dynamically when I add new rows to one of the source ranges.
I basically tried to use Arrayformulas and query formulas but I didnt found any solution.
Does anybody have any clue or idea how to solve this problem?
Thanks in Advance
volmort
You can use "Embedded Arrays" to achieve this result.
Source Data in:
D6:F9
H6:J9
L6:N9
Formula to aggregate all data ranges:
=FILTER(
{ARRAYFORMULA(D6:F9);ARRAYFORMULA(H6:J9);ARRAYFORMULA(L6:N9)}
, {ARRAYFORMULA(D6:D9);ARRAYFORMULA(H6:H9);ARRAYFORMULA(L6:L9)} <> ""
)
Note: un-populated rows in the source data ranges are "filtered" from the results. An un-populated row is a row with no data in the first column of the range.
If this result is not desired, then a simpler version with ARRAYFORUMULA could be used:
=ARRAYFORMULA(
{ARRAYFORMULA(D6:F9);ARRAYFORMULA(H6:J9);ARRAYFORMULA(L6:N9)}
)
Here is an demonstration of the solution:
https://docs.google.com/spreadsheets/d/1HTyIpaLU0dm89ZY8ka9SI0J2nywnS9QteFY1h9BxdR0/edit?usp=sharing

Is it possible to set a default value of zero when using COUNTA function in Google Sheets?

I'm using a pivot table in a Google Spreadsheet that counts the occurrences of different types of event-types on given dates. The events are listed on one sheet, with a column for "Date" and column for "Type." Based on this a Pivot Table is produced.
The trouble is that for dates when an event-type is non-existent, COUNTA returns empty. I'd rather it return 0.
The reason is for charting and statistical purposes when you create a chart from this data, it interpolates between values, ignoring empty cells. I'd prefer that it display zero on the chart on the days when these event types don't exist...
Is this possible?
UPD: sorry, I've misunderstood what you need.
What if, on another worksheet, you write the following?
=arrayformula(IF('PivotSheetName'!A1:Z100="";0;'PivotSheetName'!A1:Z100))
(This formula makes a copy of your Pivot table on the new worksheet,
replacing empty cells with 0; moreover, the control elements of the
pivot table are copied to the new worksheet as well)

Resources