Pivot Charts in google Sheets by counting non-numeric data? -


i have dataset i'd summarize in chart form. there 30 categories counts i'd display in bar chart 300+ responses. think pivot table best way this, when create pivot table , select multiple columns, each new column added gets entered sub-set of previous column. data looks following

id    country    age    thinga    thingb    thingc    thingd    thinge    thingf 1             5-9                thb                 thd                thf 2      fi        5-9     tha                                               thf 3      ga        5-9     tha                                               thf                          4             10-14                       thc 5             10-14              thb                                    thf                          6             15-18                      7      br        5-9     tha                                                                                              8             15-18                                  thd                thf                       9      fi        10-14   tha  

so, i'd able create interactive chart showed counts of "thing" items; i'd able filter based upon demographic data (e.g., country, age). notice data non-numeric, have use counta see how many there in each category.

is there simple way display chart data summarizes counts , allow me filter based on different criteria?

the query can summarize data in form want. fact have "tha", "thb", etc, instead of "1" complicates matter, 1 can transform strings numeric data on fly.

assuming data you've shown in cells a1:i10, following formula summarize it:

=query({b2:c10, arrayformula(if(len(d2:i10), 1, 0))}, "select col1, col2, count(col3), sum(col3), sum(col4), sum(col5), sum(col6), sum(col7) group col1, col2", 0) 

explanation:

  • {b2:c10, arrayformula(if(len(d2:i10), 1, 0))} creates table first 2 columns b,c (country, age) , other 6 filled 1 or 0 depending on whether cells in d-i filled or not.
  • select col1, col2, count(col3), sum(col3), ... group col1, col2 selects country, age, total count of rows country-age combination, number of rows thinga country-age combination, etc.
  • the last argument, 0, indicates there no header rows in table passed query.

it's possible give labels columns returned query, using label: see query language documentation.

label col1 'country', col2 'age', count(col3) 'total count', sum(col3) 'thinga count', ...  

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -