Answers.Body: <p>A no-coding solution is to rebuild the report in SearchKit.</p>
  <p>You need to explicitly join to the State/Provinces, but once you do, you can add a display, then use the &quot;Rewrite&quot; on the state/province, changing it to abbreviation with this token: <code>[Address_StateProvince_state_province_id_01.abbreviation]</code>. Below the screenshots is an export of my query and display, you can import it to use as an example.</p>
  <p>Attached are screenshots showing this in use.</p>
  <h3>My Query Configuration</h3>
  <p><a href="https://i.sstatic.net/6yvQH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6yvQH.png" alt="enter image description here" /></a></p>
  <h3>My Display Configuration</h3>
  <p><a href="https://i.sstatic.net/vy8Pa.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vy8Pa.png" alt="enter image description here" /></a></p>
  <pre><code>[
    [
      &quot;SavedSearch&quot;,
      &quot;save&quot;,
      {
        &quot;records&quot;: [
          {
            &quot;name&quot;: &quot;example_abbreviation&quot;,
            &quot;label&quot;: &quot;example abbreviation&quot;,
            &quot;form_values&quot;: null,
            &quot;mapping_id&quot;: null,
            &quot;search_custom_id&quot;: null,
            &quot;api_entity&quot;: &quot;Address&quot;,
            &quot;api_params&quot;: {
              &quot;version&quot;: 4,
              &quot;select&quot;: [
                &quot;id&quot;,
                &quot;Address_StateProvince_state_province_id_01.name&quot;
              ],
              &quot;orderBy&quot;: [],
              &quot;where&quot;: [],
              &quot;groupBy&quot;: [],
              &quot;join&quot;: [
                [
                  &quot;StateProvince AS Address_StateProvince_state_province_id_01&quot;,
                  &quot;LEFT&quot;,
                  [
                    &quot;state_province_id&quot;,
                    &quot;=&quot;,
                    &quot;Address_StateProvince_state_province_id_01.id&quot;
                  ]
                ]
              ],
              &quot;having&quot;: []
            },
            &quot;expires_date&quot;: null,
            &quot;description&quot;: null
          }
        ],
        &quot;match&quot;: [
          &quot;name&quot;
        ]
      }
    ],
    [
      &quot;SearchDisplay&quot;,
      &quot;save&quot;,
      {
        &quot;records&quot;: [
          {
            &quot;name&quot;: &quot;Addresses_Table_1&quot;,
            &quot;label&quot;: &quot;Addresses Table 1&quot;,
            &quot;saved_search_id.name&quot;: &quot;example_abbreviation&quot;,
            &quot;type&quot;: &quot;table&quot;,
            &quot;settings&quot;: {
              &quot;description&quot;: null,
              &quot;sort&quot;: [],
              &quot;limit&quot;: 50,
              &quot;pager&quot;: [],
              &quot;placeholder&quot;: 5,
              &quot;columns&quot;: [
                {
                  &quot;type&quot;: &quot;field&quot;,
                  &quot;key&quot;: &quot;id&quot;,
                  &quot;dataType&quot;: &quot;Integer&quot;,
                  &quot;label&quot;: &quot;Address ID&quot;,
                  &quot;sortable&quot;: true
                },
                {
                  &quot;type&quot;: &quot;field&quot;,
                  &quot;key&quot;: &quot;Address_StateProvince_state_province_id_01.name&quot;,
                  &quot;dataType&quot;: &quot;String&quot;,
                  &quot;label&quot;: &quot;Address State/Province: State&quot;,
                  &quot;sortable&quot;: true,
                  &quot;rewrite&quot;: &quot;[Address_StateProvince_state_province_id_01.abbreviation]&quot;
                }
              ],
              &quot;actions&quot;: true,
              &quot;classes&quot;: [
                &quot;table&quot;,
                &quot;table-striped&quot;
              ]
            },
            &quot;acl_bypass&quot;: false
          }
        ],
        &quot;match&quot;: [
          &quot;name&quot;,
          &quot;saved_search_id&quot;
        ]
      }
    ]
  ]
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-21T21:50:32.757Z
Answers.LastActivityDate: 2023-06-21T21:50:32.757Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>Using the <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterReportVar/" rel="nofollow noreferrer">civicrm_alterReportVar</a> hook, this can be coded fairly easily. Here is very simple code (for WordPress) to adjust the state from the full name to the abbreviation, using the CiviCRM API:</p>
  <pre><code>// Implements hook_alterReportVar
  add_filter( 'civicrm_alterReportVar', 'DNS_alterReportVar_callback', 10, 4 );
  function DNS_alterReportVar_callback($varType, &amp;$var, $reportForm) {
    if ('rows' == $varType &amp;&amp; 'Detail' == $reportForm-&gt;getname()) {
      foreach($var as $k =&gt; $row) {
         $stateProvinces = \Civi\Api4\StateProvince::get()
           -&gt;addSelect('abbreviation')
           -&gt;addWhere('name', '=', $row['civicrm_address_address_state_province_id'])
           -&gt;execute();
         $var[$k]['civicrm_address_address_state_province_id'] = $stateProvinces[0]['abbreviation'];
      }
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-23T09:08:41.390Z
Answers.Text: If you're going to write Civi code, it's generally preferable to put it in a CMS-agnostic Civi extension rather than making it specific to WP - partly because it is more discoverable showing in the list of installed Civi extensions. `civix` creates all the boilerplate for you.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-22T13:01:08.517Z
Answers.LastActivityDate: 2023-06-22T13:01:08.517Z
Answers.UserDisplayName: Hershel
Answers.Body: <p>You can either user <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterReportVar/" rel="nofollow noreferrer">alterReportVar</a> hook to alter the result or add a new column via the same hook to display State Abbreviation.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-21T10:44:21.067Z
Answers.LastActivityDate: 2023-06-22T12:45:56.323Z
Answers.LastEditDate: 2023-06-22T12:45:56.323Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>The report &quot;Membership Details&quot; at civicrm/report/instance/23 shows &quot;State/Province&quot; in the results, but we want to see the State abbreviation instead.</p>
  
Tags: <civireport><reports>
Title: How can a Report to Display State Abbreviations?
ThreadText: # How can a Report to Display State Abbreviations?
  
  (Asked by: username_0 on 2023-06-21)
  
  The report "Membership Details" at civicrm/report/instance/23 shows "State/Province" in the results, but we want to see the State abbreviation instead.
  
  **Tags:** civireport, reports
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2023-06-21. Score: 2
  
  A no-coding solution is to rebuild the report in SearchKit.
  
  You need to explicitly join to the State/Provinces, but once you do, you can add a display, then use the "Rewrite" on the state/province, changing it to abbreviation with this token: `[Address_StateProvince_state_province_id_01.abbreviation]`. Below the screenshots is an export of my query and display, you can import it to use as an example.
  
  Attached are screenshots showing this in use.
  
  ### My Query Configuration
  
  [![enter image description here](https://i.sstatic.net/6yvQH.png)](https://i.sstatic.net/6yvQH.png)
  
  ### My Display Configuration
  
  [![enter image description here](https://i.sstatic.net/vy8Pa.png)](https://i.sstatic.net/vy8Pa.png)
  
  ```
  [
    [
      "SavedSearch",
      "save",
      {
        "records": [
          {
            "name": "example_abbreviation",
            "label": "example abbreviation",
            "form_values": null,
            "mapping_id": null,
            "search_custom_id": null,
            "api_entity": "Address",
            "api_params": {
              "version": 4,
              "select": [
                "id",
                "Address_StateProvince_state_province_id_01.name"
              ],
              "orderBy": [],
              "where": [],
              "groupBy": [],
              "join": [
                [
                  "StateProvince AS Address_StateProvince_state_province_id_01",
                  "LEFT",
                  [
                    "state_province_id",
                    "=",
                    "Address_StateProvince_state_province_id_01.id"
                  ]
                ]
              ],
              "having": []
            },
            "expires_date": null,
            "description": null
          }
        ],
        "match": [
          "name"
        ]
      }
    ],
    [
      "SearchDisplay",
      "save",
      {
        "records": [
          {
            "name": "Addresses_Table_1",
            "label": "Addresses Table 1",
            "saved_search_id.name": "example_abbreviation",
            "type": "table",
            "settings": {
              "description": null,
              "sort": [],
              "limit": 50,
              "pager": [],
              "placeholder": 5,
              "columns": [
                {
                  "type": "field",
                  "key": "id",
                  "dataType": "Integer",
                  "label": "Address ID",
                  "sortable": true
                },
                {
                  "type": "field",
                  "key": "Address_StateProvince_state_province_id_01.name",
                  "dataType": "String",
                  "label": "Address State/Province: State",
                  "sortable": true,
                  "rewrite": "[Address_StateProvince_state_province_id_01.abbreviation]"
                }
              ],
              "actions": true,
              "classes": [
                "table",
                "table-striped"
              ]
            },
            "acl_bypass": false
          }
        ],
        "match": [
          "name",
          "saved_search_id"
        ]
      }
    ]
  ]
  
  ```
  
  
  ---
  
  ### Answer by username_0 on 2023-06-22. Score: 1
  
  Using the [civicrm\_alterReportVar](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterReportVar/) hook, this can be coded fairly easily. Here is very simple code (for WordPress) to adjust the state from the full name to the abbreviation, using the CiviCRM API:
  
  ```
  // Implements hook_alterReportVar
  add_filter( 'civicrm_alterReportVar', 'DNS_alterReportVar_callback', 10, 4 );
  function DNS_alterReportVar_callback($varType, &$var, $reportForm) {
    if ('rows' == $varType && 'Detail' == $reportForm->getname()) {
      foreach($var as $k => $row) {
         $stateProvinces = \Civi\Api4\StateProvince::get()
           ->addSelect('abbreviation')
           ->addWhere('name', '=', $row['civicrm_address_address_state_province_id'])
           ->execute();
         $var[$k]['civicrm_address_address_state_province_id'] = $stateProvinces[0]['abbreviation'];
      }
    }
  }
  
  ```
  
  > **Comments:**
  > **username_2**: If you're going to write Civi code, it's generally preferable to put it in a CMS-agnostic Civi extension rather than making it specific to WP - partly because it is more discoverable showing in the list of installed Civi extensions. `civix` creates all the boilerplate for you.  
  
  ---
  
  ### Answer by username_3 on 2023-06-21. Score: 1
  
  You can either user [alterReportVar](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterReportVar/) hook to alter the result or add a new column via the same hook to display State Abbreviation.
  
  
  ---
  
  