Home > Software design >  How to sort multiple columns using QUERY function together with checkboxes
How to sort multiple columns using QUERY function together with checkboxes

Time:07-08

I need to sort multiple columns using the QUERY function together with checkboxes which indicate which columns to sort. This should work with multiple columns.

enter image description here

This is the formula:

=IFERROR(ARRAYFORMULA(
    QUERY(
        {AI4:AY101, TRIM(FLATTEN(QUERY(TRANSPOSE(AJ4:AY101),,9^9)))}, 
        "Select Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11, Col12, Col13, Col14, Col15, Col16, Col17
        where Col18 is not null
        order by 
        Col"&$P$1&" "&$P$3&"
        ", )),"Loading…")

It works for single columns if I check only 1 checkbox. Is there a way to make it sort multiple columns if I check multiple checkboxes?

Demo file:
enter image description here

  • Related