google-sheetspivot-tablegoogle-query-language

QUERY function to create pivot table with strings


I'm trying to solve this problem with Google Sheets.

What I've tried:

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.)

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.

In Excel, I could also do something complicated with four separate VBA scripts to achieve the same result. However for me, translating that to Google Scripts API is challenging.

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 have 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.

Any ideas? What is the simplest (hopefully non-scripting) way to do this?


Solution

  • .. which means B has to only have numbers...

    That's a assumption. And not a very good one.

    Since you did not provide a sample question yourself. For the linked Question, it's simple:

    =QUERY(A1:C5,"Select A, max(C) group by A pivot B", 1)
    

    Mark this as answered by clicking ☑ on the left.