Home > OS >  Google Sheets - Using INDIRECT (or alternative) within a query
Google Sheets - Using INDIRECT (or alternative) within a query

Time:12-09

I am currently using this formula:

=SORT(QUERY(G:Z, "select K,count(K) where K is not null group by K label count(K)''"),2,TRUE)

I have to replace all instances of "K" with a column letter that is written in cell B2, so I can quickly change the entire formula by simply entering the letter in the cell.

Any advice?

Thanks

CodePudding user response:

Use string concatenation:

=SORT(QUERY(E:K, "select " & D1 &" ,count(" & D1 &") where " & D1 &" is not null group by " & D1 &" label count(" & D1 &")''"),2,TRUE)

enter image description here

CodePudding user response:

as already suggested enter image description here

demo sheet

  • Related