Knowledge Drop

Can I remove GROUP BY in Looker-generated SQL?

Userlevel 5
  • Looker Staff
  • 173 replies

Last tested: April 2021


By default, Looker will group by all dimensions selected. The exception to this is if you select the primary key with no measures, and there are no joins in the query that would cause a fanout of the primary key (as defined by the relationship parameters in the joins). Then Looker knows grouping is pointless and does not add a GROUP BY.

You can use cancel_grouping_fields (docs) at the explore level to define a list of fields which should also remove the GROUP BY when any of the fields in the list are selected in the explore.

If your use case is a little different, and defining a cancel_grouping_fields at the explore level won't help you achieve your goals, please leave feedback for the product team (instructions here)!


This content is subject to limited support.                




0 replies

Be the first to reply!