Google Sheets - QUERY order by dependent drop down

Viewed 115

I am trying to setup a QUERY with dynamic ordering. I've tried to link the ORDER BY function to the output of the dropdown menu but that doesnt seem to work. I have recreated the problem with a simple example: https://docs.google.com/spreadsheets/d/1m3Lhm5lp2DW7XF8hRbDAiOAAsOyCXrie-Nc-0bWG6hA/edit?usp=sharing

I've created a table (3x4) with three variable and would like to dynamically sort the table by each variable through QUERY both ascending and descending.

Would also be interested to learn if it's possible to dynamically setup the direction (ACS or DESC).

Any suggestions would be much appreciated.

Kind regards,

Webko

1 Answers

try:

=QUERY({A2:C6}, "order by Col"&MATCH(F1, A2:C2, 0)&" "&G1)

enter image description here

where G1 dropdown is asc,desc

Related