title: QUERY function to create pivot table with strings
body: <p>I'm trying to solve <a href="https://stackoverflow.com/questions/32767117/pivot-in-excel-without-aggregation-to-show-text-not-numbers">this</a> problem with Google Sheets.</p>
  
  <p>What I've tried:</p>
  
  <p>In Google Sheets, I can use the built-in Pivot Table function to make pivot tables. However, similarly to Excel (before 2016), GSheets lacks the ability to create pivot tables with textual values rather than numbers. (As it says in the link above.)</p>
  
  <p>In Excel, as it says in the link above, you can use MS Power Query Add-in, but I don't have that in GSheets.</p>
  
  <p>In Excel, I could also do something complicated with <a href="https://www.homeworkhelponline.net/blog/programming/excel-pivot-sub-group" rel="nofollow noreferrer">four separate VBA scripts</a> to achieve the same result. However for me, translating that to Google Scripts API is challenging.</p>
  
  <p>I can also use GSheets' QUERY function to create pivot tables. However again it appears I can't get textual values in my pivot table. For example a in query like:
  =QUERY(table,"SELECT C, count(B) GROUP BY C",1)
  which would otherwise create a pivot table, I <em>have</em> to put count(B) or max(B) or min(B) or avg(B), which means B has to only have numbers. If I just replace that with B, it doesn't work.</p>
  
  <p>Any ideas? What is the simplest (hopefully non-scripting) way to do this?</p>