## Subtotal IF formula - google-sheets

Sorry if this is a real basic question - But I'm not having any luck at all.
How would I subtotal only cells within the G column that meet the following requirements based on their row:
Contain the word 'test' in column A
Contain the date '01/01/2023' in column C
I've tried using SUMIF, but not sure how to incorporate the 'Subtotal 109'?

The SUBTOTAL function only operates on ranges. To accomplish what you're asking for you have to first filter the data in a separate range and then run SUBTOTAL.

## Related

### sumif formula to calculate values

I have this data set where I am using this formula to calculate the outstanding course fee but when I am putting the amount received its not deducting the remaining amount from the total course fee and showing in the next record. I am not able to work this out with sumif formula, any help will be highly appreciated. =IF(AND(ISBLANK(A5)),"",VLOOKUP(A5,Student_Registration!$B$5:$H$2000,7,0)-SUMIF($A$5,A5,$I$5)) Sample worksheet : https://docs.google.com/spreadsheets/d/1roEXEuBBwHU8lKV_QruY6hVjYOOkpwAwAI5x8yuYfZ8/edit?usp=sharing

Since your Column G and Column I already have value to be used, why don't you use the following simplified formula to obtain the expected outcome? What you need is to used to formula to populate the value in Column I, hope it will help. =G5-SUMIF($A$5:A5,A5,$I$5:I5)

### Google Sheets Count Unique Dates based upon a criteria in different columns

I am trying to find a formula that will give me the count of unique dates a persons' name appears in one of two different columns and/or both columns. I have a set of data where a person's name may show up in a "driver" column or a "helper" column, multiple times over the course of one day. Throughout the day some drivers might also be helpers and some days a driver may come in for duty but only as a helper. Basically all drivers can be helpers, but not all helpers can be drivers. I've attached a link to a sample sheet for more clarity. https://docs.google.com/spreadsheets/d/1GqNa1hrViX4B6mkL3wWcqEsy87gmdw77DhkhIaswLyI/edit?usp=sharing I've created a REPORTS tab with a SORT(UNIQUE(FLATTEN)) Formula to give me a list of the names that appear in the DATA Tab. I'm looking for a way to count the unique dates a name from the name (Column A of the REPORTS Tab) appears in either of the two columns (Column B and/or C of the DATA Tab) to determine the total number of days worked so I can calculate the total number of days off over the range queried. I've tried several iterations of countif, countunique, and countuniqueifs but cannot seem to find a way to return the correct values. Any advice on how to make this work would be appreciated.

I think if you put this formula in cell b7 you'll be set. You can drag it down. =Counta(Unique(filter(DATA!A:A,(DATA!C:C=A7)+(DATA!B:B=A7)))) Here's a working version of your file. For anyone interested, Google Sheets' Filter function differs slightly from Excel's Filter function because Sheets attempts to make it easier for users to apply multiple conditions by simply separating each parameter with a comma. Example: =filter(A:A,A:A<>"",B:B<>"bad result") will provide different results between the Sheets and Excel. Excel Filter requires users to specify multiple conditions within parenthesis and denote each criterion be flagged with an OR condition with a + else an AND condition with a multiplication sign *. While this can appear daunting and bizarre to multiply arrays that have text in it, it allows for more flexibility. To Google's credit, if one follows the required Excel Syntax (as I did in this answer) then the functions will behave the same.

delete what you got and use: =QUERY(QUERY(UNIQUE({DATA!A:B; DATA!A:A, DATA!C:C}), "select Col2,count(Col1),"&D2&"-count(Col2) where Col2 is not null group by Col2"), "offset 1", 0)

### How to use AVERAGEIF in Google Sheets, only addressing columns with a specific text

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

### Total Value based on Group cross reference? (Google Sheets)

I'd like to query a couple of tables to come up with a total sum of the value of a set of items, but with the price being dependent on data in another cell range, then grouping it based on category. For example, say I have a data table containing name, category, and price of some grocery items. Another table I store my current inventory of groceries. I would like to calculate the value of, say, all my fruit. Here is an editable example: https://docs.google.com/spreadsheets/d/1y2fLgwrsMr-dWojy3uYZ1Qs2U01AP3RlT_PI2txwZRE/edit?usp=sharing Not sure the best way to approach this? Thanks for any guidance!

Solution Use VLOOKUP for searching the right item of your inventory and then multiply it with the value of the product you made the search with. For more info about VLOOKUP check this documentation. =VLOOKUP(E3,$A$3:$C$11,3,FALSE)*F3 With these values, create a column next to Quantity indicating the total price for each product (as show in the picture below). Then, create another column with the Type of each item performing a similar VLOOKUP formula: =VLOOKUP(E3,$A$3:$C$11,2,FALSE) Finally, use these two columns as input ranges to apply a SUMIF formula for adding up the items of each group: =SUMIF(H3:H6,"Fruit",G3:G6) For more info about SUMIF check this documentation. I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)

### Google Sheets Formula for Pulling Specific Values in Two Ways

I'm trying to do a couple of different things with a spreadsheet in Google and running into some problems with the formulas I am using. I'm hoping someone might be able to direct me to a better solution or be able to correct the current issue I'm having. First off all, here is a view of the data on Sheet 1 that I am pulling from: Example Spreadsheet The first task I'm trying to accomplish is to create a sheet that lists all of these shift days with the date in one column and the subject ("P: Ben" or S: Nicole") in another column. This sheet would be used to import the data via a CSV into our calendar system each month. I tried doing an Index-Match where it used the date to pull the associated values however I found that I had to keep adjusting the formula offsets in order to capture new information. It doesn't seem like Index-Match works when multiple rows/columns are involved. Is there a better way to pull this information? The second task I am trying to accomplish is to create a new tab which lists all the dates a specific person is assigned too (that way this tab will update in real time and everyone can just look at their own sheet to see what days they are on-call). However, I run into the same problem here because for each new row I have to change the formula to reflect the correct information otherwise it doesn't pull the correct cell when it finds a match. I would appreciate any and all information/advice on how to accomplish these tasks with the formula combination I mentioned or suggestions on other formulas to use that I have not been able to find. Thanks in advance!

Brandon. There are a few ways to attack your tasks, but looking at the structure of your data, I would use curly brackets {} to create arrays. Here is an excerpt of how Google explains arrays in Sheets: You can also create your own arrays in a formula in your spreadsheet by using brackets { }. The brackets allow you to group together values, while you use the following punctuation to determine which order the values are displayed in: Commas: Separate columns to help you write a row of data in an array. For example, ={1, 2} would place the number 1 in the first cell and the number 2 in the cell to the right in a new column. Semicolons: Separate rows to help you write a column of data in an array. For example, ={1; 2} would place the number 1 in the first cell and the number 2 in the cell below in a new row. Note: For countries that use commas as decimal separators (for example €1,00), commas would be replaced by backslashes () when creating arrays. You can join multiple ranges into one continuous range using this same punctuation. For example, to combine values from A1-A10 with the values from D1-D10, you can use the following formula to create a range in a continuous column: ={A1:A10; D1:D10} Knowing that, here's a sample sheet of your data. First Task: create a sheet that lists all of these shift days with the date in one column and the subject ("P: Ben" or S: Nicole") in another column. To organize dates and subjects into discrete arrays, we'll collect them using curly brackets... Dates: {A3:G3,A7:G7,A11:G11,A15:G15} Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17} This actually produces two rows rather than columns, but we'll deal with that in a minute. You'll note that, because there are two subjects per every one date, we need to effectively double each date captured. Dates: {A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15} Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17} Still with me? If so, all that's left is to (a) turn these two rows into two columns using the TRANSPOSE function, (b) combine our two columns using another pair of curly brackets and a semicolon and (c) add a SORT function to list the dates in chronological order... =SORT(TRANSPOSE({{A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15};{A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}}),1,TRUE) Second Task: create a new tab which lists all the dates a specific person is assigned too (that way this tab will update in real time and everyone can just look at their own sheet to see what days they are on-call). Assuming the two-column array we just created lives in A2:B53 on a new sheet called "Shifts," then we can use the FILTER function and SEARCH based on each name. The formula at the top of Ben's sheet would look like this: =FILTER(Shifts!A2:B53,SEARCH("Ben",Shifts!B2:B53)) Hopefully this helps, but please let me know if I've misinterpreted anything. Cheers.