Get better at working with Google Sheets! Join 50,000 readers to get an actionable tip in your inbox every Monday.
Welcome to the Google Sheets Tips newsletter #293, your Monday morning espresso, in spreadsheet form! This week, I'm discussing spreadsheets live on YouTube on the Totally Unscripted show. The episode airs this Wednesday (6th March) at 3 pm Eastern time. Tune in here and ask your questions! A big thank you to this week's sponsors who help keep this newsletter free to read: ➜ NewsI. II. _______ ➜ Google Sheets Tip #293: Conditional counts and sums (when certain things are true)In this tip, we look at the COUNTIF, COUNTIFS, SUMIF, and SUMIFS functions. Suppose we have this dataset: Named RangesLet's add Named Ranges to make our lives easier. Named ranges are labels that we attach to ranges so that we can refer to them easily in formulas. Highlight A2:A11 and go to the menu: Data > Named ranges Name this range "customers". Now, we can write "customers" instead of "A2:A11" in our formulas. Repeat for the products and revenue in columns B and C. Our named ranges should look like this: Conditional Counts and SumsLet's run through a series of examples, from simple to more complex. To count all the "Office Pro" products, we use this COUNTIF formula: =COUNTIF(products,"Office Pro") To sum the revenue for the "Office Pro" products, use this SUMIF with the revenue range: =SUMIF(products,"Office Pro",revenue) If we use more than one conditional test, we need to use the COUNTIFS or SUMIFS functions. Here, we use a COUNTIFS to count "Office Pro" products with revenue over $20,000: =COUNTIFS(products, "Office Pro", revenue, ">20000") And if we want to sum the revenue associated with these products, we use a SUMIFS formula: =SUMIFS(revenue, products, "Office Pro", revenue, ">20000") WildcardsThese conditional formulas have a hidden power... they accept wildcard characters! They support three wildcards:
Thus, to count all the "Pro" products (i.e. "Office Pro" and "Alpha Pro Tool") in our data, we use a COUNTIF with star wildcards on either side of "Pro": =COUNTIF(products, "*Pro*") This matches any strings containing "Pro", even just "Pro" on its own. To sum, use a SUMIF with wildcards: =SUMIF(products, "*Pro*", revenue) The ? represents a single character. In our example, we have "Customer 01" and "Customer 03". Suppose we want to count both of these customers, then we can use the ? wildcard to represent the 1 or 3 as follow: =COUNTIF(customers, "Customer 0?") Finally, we can sum with this wildcard character like so: =SUMIF(customers, "Customer 0?", revenue) Note: COUNTIF, COUNTIFS, SUMIF, and SUMIFS functions are case insensitive. E.g. "Office Pro", "OFFICE PRO", or "office pro" will all produce identical results. _______ If you enjoyed this newsletter, please forward it to a friend who might enjoy it. Have a great week! Cheers, |
by Ben Collins
Get better at working with Google Sheets! Join 50,000 readers to get an actionable tip in your inbox every Monday.
Hi Reader, Greetings from sunny Harpers Ferry! ☀️ The rain has stopped (until tomorrow at least!) and I'm finally feeling better so I'm optimistic for the week ahead! Welcome to this issue of the Google Sheets Tips newsletter, #303, your Monday morning espresso, in spreadsheet form! Wow, that's a lot of exclamation points in the first few sentences! Oops, that was another. It's the optimism I feel today ;) Today I want to share a data visualization technique for showing change between two...
Hi Reader, Welcome to the Google Sheets Tips newsletter #302, your Monday morning espresso, in spreadsheet form! I'm sick at the moment, battling a nasty sinus infection. I'm not a good patient because I'm too impatient. There are so many things to do! But I'm wiser now than a decade ago and realize that rest comes first. At least I wrote this week's newsletter before getting sick. And I think it's an interesting newsletter. But it's one that might divide opinion. Purists will dislike it...
Hi Reader, Welcome to the Google Sheets Tips newsletter #301, your Monday morning espresso, in spreadsheet form. Earlier this year I sat down to record a new course but progress stalled before I got far. I've been creating courses for 7 years and realized that I need to freshen things up. One change I want to make is to inject more meaning into my work. I'm deeply interested in our natural world and protecting it for future generations. I want to use the skills I have and apply them towards...