By using the QUERY function you can achieve your goal.
=QUERY(Data!A1:B6;"select A, sum(B), count(B) group by A")
Using other functions, makes it achievable as well.
add this formula in A2:
add the following formulas in B2 and C2 and copy down to B4 and C4 respectivey
Use the following formula to obtain the query you want.
In the reference it is explained by Ahab that + and * can be used as boolean expressions, as OR and AND.
The solution with the IFERROR (see revision history) is of no use in this case, unless you want to find a particular string:
In addition to using the ever-useful UNIQUE function around FILTER, as user79865 suggests, you can also use UNIQUE around the original QUERY function (which may be more applicable and helpful in other scenarios to preserve the options and flexibility of QUERY when FILTER is not enough).
=UNIQUE(QUERY(A1:B6,"SELECT A WHERE B = 'SubCatA'"))
This returns a #VALUE! error if the search term isn't found:
=IF(SEARCH("sites", B2) > 0, 1, 0)
This uses the same logic but catches the error and returns a 1/0 for success/failure:
=IF(IFERROR(SEARCH("sites", B2) > 0, 0), 1, 0)
Here's a generic script that will autosort based on the 1st column, and assumes a Header row.
To create a script:
In the menu, go to Tools -> Script Editor...
In the empty code window, paste the following code, which will run automatically whenever a cell is edited:
// LinkBack to this script:
Is it at all possible to use column headers like this?
Yes, it is possible. First, you need to use MATCH to get the column number of the column whose value matches 'Name'. Then you need to use ADDRESS to get the cell reference. Finally, you need to use SUBSTITUTE to remove the row number from the cell reference.
=QUERY(Sheet1!A1:C,"SELECT A, B, C where "&...
In Google Spreadsheets, I would do it a bit different.
=COUNTA(SPLIT(A1, " "))
The SPLIT function is only available in Google Spreadsheet and will split the cell's content on every space (" "). The COUNT function will simply count the instances.
The Excel formula gives the same answer, but a bit more laborious:
If you, as Ryan Shillington suggests, want to know the number of cells within a range that has "sites" in it, you might try:
The * acts as a wildcard notion, so it will look for a match anywhere within the cell, not just an exact match for the whole cell.
I've also done this with a cell reference instead of "sites", but ...
You need to add a helper column within the QUERY formula, like so:
"SELECT Col1, COUNT(Col3) WHERE Col2 = 'SubCatA' GROUP BY Col1 LABEL COUNT(Col3) ''"
Adding another QUERY formula will help to remove the helper column:
"SELECT Col1, COUNT(Col3) WHERE Col2 = 'SubCatA' GROUP BY ...
I have had a similar issue, with trying to sort a UNIQUE dataset.
the way i got around it was by creating another sheet and using the '=QUERY()' function to call the sheet with the UNIQUE list on it. This way you can add a ORDER BY statement to the query.
so in your example, Expenses has the source data, the summary table has the Summary data (with the ...
The third parameter you speak of in the QUERY function, is meant to control the headers.
If set to be -1, then the Google Spreadsheet will depict its own choice in choosing headers, based on the data available:
I've used the following data set:
If set to be 0, then no header will be used, leaving:
If set to be 1, then the first row will be used, leaving:
Make a new sheet inside your current spreadsheet. Put two columns in it:
VoiceType Sort order
In your main worksheet (the one with the list of people), in a new column put a formula like this:
Note that I have used the UPPER() function in case some of the ...
=AVERAGE(OFFSET(A:A;COUNT(A:A)-7 + MATCH(TRUE;INDEX(A:A<>0);0)-1;0))
First we count how many numbers are in row A with =COUNT(A:A). Cells containing text won't be counted. Our example would give us 9
From this number we subtract 7 since you want the average of the last 7 values: =COUNT(A:A)-7. This will give us a 2.