title: How to set the number of columns of a Qgis legend based on the number of legend items in the atlas feature?
body: <p>Qgis 3.18
  I am working on an atlas showing forest use of different municipalities. The number of items in my legend varies a lot from one city to another. Therefore I would like to set the number of columns depending on the number of legend items in the current atlas feature.</p>
  <p>I am trying to set it with an expression of the like :<br>
  CASE<br>
      WHEN  count(@symbol_id)&lt;= 3 THEN 1 <br>
      WHEN count(@symbol_id) &gt; 6 AND count(@symbol_id) &lt;= 9 THEN 3 <br>
      WHEN count(@symbol_id) &gt; 9 AND count(@symbol_id) &lt;= 12 THEN 4 <br>
      ELSE 5 <br>
  END</p>
  <p>&quot;count(@symbol_id)&quot; does not return the right number, how can I refer to it ?</p>