Search code examples
google-sheetsgoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Sort by Column C but group the values from Column F


For simplicity, I would like it to be separated by country (written at the beginning of the names in Column C), but those that have data in Column F stay together, and those that don't have it are separated.

=QUERY(Sheet7!B1:G,"Where C is not null Order by C")

enter image description here

In the country Brazil it is noted that the lines with values in F are not grouped. This is what I would like to group together, in alphabetical order as in Column C, but in the list of each country came first those with data in Column F.

I tried to use Query with Group by after referring a member (Player0), the first answer to the question, but unfortunately I was not able to get what I need to do.

Right way would be:

enter image description here


Solution

  • Here result will sort the country and F:

    = array_constrain 
      ( arrayformula 
        ( query
          ( SORT
            ( { Sheet7!B1:G, 
                mid (Sheet7!C1:C,1,find("/",Sheet7!C1:C,find("/",Sheet7!C1:C,2)+1)), 
                Sheet7!F1:F
              }
              , 7, true, 8, true
            ) 
            ,"Select *" 
          )
        )
        ,ROWS(Sheet7!B1:B),6
      )