<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Get union of other fields</title><link>https://community.appian.com/discussions/f/general/24238/get-union-of-other-fields</link><description>So I have a CDT with a bunch of fields in it. One of the fields is a category, while the other is string. That string field will be identical throughout a particular category, but may or may not be different in different categories. So for example: 
</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Get union of other fields</title><link>https://community.appian.com/thread/93496?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2022 17:38:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:14dffa36-e964-4038-aa60-66b99698bb34</guid><dc:creator>Marco</dc:creator><description>&lt;p&gt;That sounds like what I need, perfect. Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get union of other fields</title><link>https://community.appian.com/thread/93495?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2022 16:12:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0dda748f-b00d-4627-a869-6b981094b72a</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;If the string data is guaranteed to be identical&amp;nbsp;within a category, you could probably make it easy and just return the first item in each category list. Here&amp;#39;s an example:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: local!data: {
    {
      category: &amp;quot;round things&amp;quot;,
      string: &amp;quot;bubbles, &amp;lt;otherdata&amp;gt;&amp;quot;
    },
    {
      category: &amp;quot;round things&amp;quot;,
      string: &amp;quot;bubbles, &amp;lt;otherdata&amp;gt;&amp;quot;
    },
    {
      category: &amp;quot;soapy things&amp;quot;,
      string: &amp;quot;bubbles, &amp;lt;otherdata&amp;gt;&amp;quot;
    },
    {
      category: &amp;quot;hard things&amp;quot;,
      string: &amp;quot;rocks, &amp;lt;otherdata&amp;gt;&amp;quot;
    }
  },
  local!uniqueCategories: union(touniformstring(local!data.category), touniformstring({})),
  a!forEach(
    items: local!uniqueCategories,
    expression: index(
      local!data.string,
      
      /* Only pulls back the first string from all the categories */
      index(
        
        /* Identifies the rows that match the same category */
        wherecontains(
          tostring(fv!item),
          touniformstring(local!data.category),
        ),
        1,
        {}
      ),
      {}
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>