Answers.Body: <p>It turns out the filters option of the _columns is what I wanted, but civicrm_group is bit of a special case.  The problem I finally stumbled upon is at the end of the __construct function is a call to parent::__construct().
  (I have a lot of columns defined, so for me it is a ways down so I didn't see it right away.)  That ends up overwriting what I had in the filter for civicrm_group.  Right above this call, two variables get set to TRUE, _groupFilter and _tagFilter.  Setting the groupFilter to false prevents the parent construct from overwriting it.</p>
  <p>So for completeness in the answer I'll give what code I ended up with for what it's worth.</p>
  <p>So at the top of the function __construct I have this.  There are probably better ways to do this:</p>
  <pre><code>  $sql = &quot;select id, title
            from civicrm_group g
            where g.id in (
                select n.child_group_id
                from   civicrm_group_nesting n
                where  n.parent_group_id in (124,125))          
            order by title&quot;;
  
  $dao = CRM_Core_DAO::executeQuery($sql);
  
  while ($dao-&gt;fetch()) {
    $MyGroups[$dao-&gt;id] = $dao-&gt;title;
  }
  </code></pre>
  <p>then in the filter section of _columns for group I have this</p>
  <pre><code>     'filters' =&gt; array(
          'gid' =&gt; array(
          'name' =&gt; 'group_id',
          'title' =&gt; E::ts('My Groups'),
          'operatorType' =&gt; CRM_Report_Form::OP_MULTISELECT,
          'type' =&gt; CRM_Utils_Type::T_INT,
          'options' =&gt; $MyGroups,
          ),
        ),
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-31T03:19:12.920Z
Answers.LastActivityDate: 2023-03-31T03:19:12.920Z
Answers.UserDisplayName: Paul-Tahoe
Body: <p>I've written a custom report, lots of trial and mostly error.  One of the columns is group.  Since we have almost 300 groups, I'd like to limit the groups the user can include in the report to a subset.  (Only certain groups make sense with this report and no one wants to wade through 300 groups to find the several they want.)</p>
  <p>Clearly using filters in the _columns is the way to go but I'm not sure just what to put where.  I've found examples of hard coded values but I'd like a bit of sql.  Maybe there are some examples that my grep didn't find of sql statements.</p>
  <p>Here is the basic sql I'd like to use.  Maybe it only needs to return the id instead of the title.</p>
  <p><code>select g.title from civicrm_group g, civicrm_group_nesting n where g.id = n.child_group_id and parent_group_id in (124, 125)</code></p>
  <p>The report already limits the groups to these but users may only want one or two groups and not the full 20 or so groups the defaults return.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-10T19:02:36.877Z
Comments.Text: Is this a custom CiviReport or is it made with SearchKit?
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-11T01:01:43.483Z
Comments.Text: Custom CiviReport.  I have a custom search and want to automatically email the results on a weekly bases.  I don't think that is possible with queries and I as far as I can tell maybe not with SearchKit.  Plus since I had the sql already (46 lines of code) it seemed far easier to just make it a custom civireport using civix generate:report than to recreate it all in SearchKit.  Plus I don't see how to have a derived field in SearchKit and I'm using a couple of views I created which I don't think are available through SearchKit
Comments.UserDisplayName: Paul-Tahoe
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-14T13:39:51.560Z
Comments.Text: In that case you might be able to achieve it by overriding that field in the `buildForm` function.
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-23T00:17:07.927Z
Comments.Text: The filters of _columns seem like one should be able to do this.  There is the options parameter of filters that the civi reports reference docs talk about fixed values, e.g. array('1'=>'Low', '2'=>'Medium', '3'=>'High').  Everything I've tried to populate an array hasn't worked.
Comments.UserDisplayName: Paul-Tahoe
Tags: <custom-reports>
Title: Is there a way in a custom report to only give the user certain choices in filters, e.g. only show them groups that belong to a parent group?
ThreadText: # Is there a way in a custom report to only give the user certain choices in filters, e.g. only show them groups that belong to a parent group?
  
  (Asked by: username_0 on 2023-03-10)
  
  I've written a custom report, lots of trial and mostly error. One of the columns is group. Since we have almost 300 groups, I'd like to limit the groups the user can include in the report to a subset. (Only certain groups make sense with this report and no one wants to wade through 300 groups to find the several they want.)
  
  Clearly using filters in the \_columns is the way to go but I'm not sure just what to put where. I've found examples of hard coded values but I'd like a bit of sql. Maybe there are some examples that my grep didn't find of sql statements.
  
  Here is the basic sql I'd like to use. Maybe it only needs to return the id instead of the title.
  
  `select g.title from civicrm_group g, civicrm_group_nesting n where g.id = n.child_group_id and parent_group_id in (124, 125)`
  
  The report already limits the groups to these but users may only want one or two groups and not the full 20 or so groups the defaults return.
  
  **Tags:** custom-reports
  
  > **Comments:**
  > **username_1**: Is this a custom CiviReport or is it made with SearchKit?  
  > **username_0**: Custom CiviReport.  I have a custom search and want to automatically email the results on a weekly bases.  I don't think that is possible with queries and I as far as I can tell maybe not with SearchKit.  Plus since I had the sql already (46 lines of code) it seemed far easier to just make it a custom civireport using civix generate:report than to recreate it all in SearchKit.  Plus I don't see how to have a derived field in SearchKit and I'm using a couple of views I created which I don't think are available through SearchKit  
  > **username_1**: In that case you might be able to achieve it by overriding that field in the `buildForm` function.  
  > **username_0**: The filters of _columns seem like one should be able to do this.  There is the options parameter of filters that the civi reports reference docs talk about fixed values, e.g. array('1'=>'Low', '2'=>'Medium', '3'=>'High').  Everything I've tried to populate an array hasn't worked.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-03-31. Score: 1
  
  It turns out the filters option of the _columns is what I wanted, but civicrm_group is bit of a special case.  The problem I finally stumbled upon is at the end of the __construct function is a call to parent::__construct().
  (I have a lot of columns defined, so for me it is a ways down so I didn't see it right away.)  That ends up overwriting what I had in the filter for civicrm_group.  Right above this call, two variables get set to TRUE, _groupFilter and _tagFilter.  Setting the groupFilter to false prevents the parent construct from overwriting it.
  So for completeness in the answer I'll give what code I ended up with for what it's worth.
  So at the top of the function __construct I have this.  There are probably better ways to do this:
    $sql = "select id, title
            from civicrm_group g
            where g.id in (
                select n.child_group_id
                from   civicrm_group_nesting n
                where  n.parent_group_id in (124,125))          
            order by title";
  
  $dao = CRM_Core_DAO::executeQuery($sql);
  
  while ($dao->fetch()) {
    $MyGroups[$dao->id] = $dao->title;
  }
  
  then in the filter section of _columns for group I have this
       'filters' => array(
          'gid' => array(
          'name' => 'group_id',
          'title' => E::ts('My Groups'),
          'operatorType' => CRM_Report_Form::OP_MULTISELECT,
          'type' => CRM_Utils_Type::T_INT,
          'options' => $MyGroups,
          ),
        ),
  
  
  ---
  
  