<?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>Rendering different values based on count function</title><link>https://community.appian.com/discussions/f/general/17927/rendering-different-values-based-on-count-function</link><description>I have a constant that stores three different values. My table has a list of items, where the constant can be either pass, fail, or na. 
 
 I want to have three different sections on a new interface where it will show one section as all items that are</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Rendering different values based on count function</title><link>https://community.appian.com/thread/70577?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2019 22:23:43 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ed10ee0c-0cac-469c-a294-65e0861d1a33</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;It might be even easier if you have the data coming from a database. You can set up your query to aggregate on the field you want to compare to the constant. Then, you can use wherecontains to find the count of the associated data. Here&amp;#39;s an example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!query:a!queryEntity(
    entity: cons!&amp;lt;YOUR ENTITY HERE&amp;gt;,
    query: a!query(
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: -1
      ),
      aggregation: a!queryAggregation(
        aggregationColumns: {
          a!queryAggregationColumn(field: &amp;quot;&amp;lt;YOUR FIELD NAME HERE&amp;gt;&amp;quot;, isGrouping: true),
          a!queryAggregationColumn(field: &amp;quot;id&amp;quot;, aggregationFunction: &amp;quot;COUNT&amp;quot;, alias: &amp;quot;count&amp;quot;)
        }
      )
    )
  ),
  a!textField(
    label: &amp;quot;Count of Constant Value 1&amp;quot;,
    readOnly: true,
    value: index(
      local!query.data.count,
      wherecontains(cons!&amp;lt;YOUR CONSTANT HERE&amp;gt;[1], touniformstring(local!query.data.&amp;lt;YOUR FIELD NAME HERE&amp;gt;)),
      0
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In this example, I group by the field in the database to create the correct count. Then, I find whether that value exists in the output using wherecontains(). I can then find the associated count using the index() function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rendering different values based on count function</title><link>https://community.appian.com/thread/70574?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2019 20:47:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8a4e8f8f-d18e-478f-947b-e3043413fc63</guid><dc:creator>Omkar Ambardekar</dc:creator><description>&lt;p&gt;You would just be replacing local!difficulty with your status constant (or a db query fetching ref data) and local!randomItems with a queryEntity that returns the items from the db.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rendering different values based on count function</title><link>https://community.appian.com/thread/70573?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2019 20:38:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7c9fbf09-9880-4485-8450-da7b6809d77e</guid><dc:creator>Jorge Arellano</dc:creator><description>&lt;p&gt;What if I have everything coming from the database?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rendering different values based on count function</title><link>https://community.appian.com/thread/70568?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2019 17:56:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d682e903-317d-4efb-ac1f-afcb441d7720</guid><dc:creator>Omkar Ambardekar</dc:creator><description>&lt;p&gt;Hi Jorge, I am not sure how the data in your tables is structured. But you could take a look at the sample code I have posted below and build your interface similarly:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;with(&lt;br /&gt; local!difficulty: {&amp;quot;HIGH&amp;quot;, &amp;quot;MEDIUM&amp;quot;, &amp;quot;LOW&amp;quot;},&lt;br /&gt; local!randomItems: {&lt;br /&gt; {task: &amp;quot;Build a pyramid&amp;quot;, difficulty: &amp;quot;HIGH&amp;quot;},&lt;br /&gt; {task: &amp;quot;Run a marathon&amp;quot;, difficulty: &amp;quot;MEDIUM&amp;quot;},&lt;br /&gt; {task: &amp;quot;Space travel&amp;quot;, difficulty: &amp;quot;HIGH&amp;quot;},&lt;br /&gt; {task: &amp;quot;Make coffee&amp;quot;, difficulty: &amp;quot;LOW&amp;quot;}&lt;br /&gt; },&lt;br /&gt; a!forEach(&lt;br /&gt; local!difficulty,&lt;br /&gt; a!richTextDisplayField(&lt;br /&gt; value: {&lt;br /&gt; with(&lt;br /&gt; local!indices: wherecontains(tostring(fv!item), touniformstring(local!randomItems.difficulty)),&lt;br /&gt; {&lt;br /&gt; a!richTextItem(&lt;br /&gt; text: length(local!indices)&amp;amp;&amp;quot; &amp;quot;&amp;amp;fv!item&amp;amp;&amp;quot; items:&amp;quot;,&lt;br /&gt; ),&lt;br /&gt; char(10),&lt;br /&gt; a!richTextBulletedList(&lt;br /&gt; items: a!forEach(local!indices,&lt;br /&gt; a!richTextItem(&lt;br /&gt; text: index(index(local!randomItems, fv!item, {}), &amp;quot;task&amp;quot;, {})&lt;br /&gt; )&lt;br /&gt; )&lt;br /&gt; )&lt;br /&gt; }&lt;br /&gt; )&lt;br /&gt; }&lt;br /&gt; )&lt;br /&gt; )&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rendering different values based on count function</title><link>https://community.appian.com/thread/70565?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2019 16:49:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2e529c42-1dc1-4c59-9748-a37623db485d</guid><dc:creator>Jorge Arellano</dc:creator><description>&lt;p&gt;The content that the constant holds are statuses. So when an item is in status 1, I want it to count it and give me the total count of items that are only in status 1. Same for the other two statuses.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>