<?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>How to count frequency of data in dataset</title><link>https://community.appian.com/discussions/f/user-interface/13143/how-to-count-frequency-of-data-in-dataset</link><description>Hi , 
 
 Do we have any function in appian which can count frequency of data in dataset. 
 Test Dataset - 
 Column 1 Column 2 Column 3 
 Row 1 - A B C 
 Row 2- A B D 
 Row 3 - C B E 
 Row 4- C A F 
 Row 5- C G H 
 
 Here i want to put one validation that</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to count frequency of data in dataset</title><link>https://community.appian.com/thread/59546?ContentTypeID=1</link><pubDate>Fri, 24 Aug 2018 14:54:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d4e80fb5-e0f9-4930-8aab-aeb4691e6f47</guid><dc:creator>ankita0004</dc:creator><description>You have to apply this on both fields&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if(or(rule!APN_isBlank(ri!Data[ri!index].sgId),rule!APN_isBlank(ri!Data[ri!index].mtId)),{},&lt;br /&gt;
count(&lt;br /&gt;
whereContains(&lt;br /&gt;
ri!Data[ri!index].sgId,&lt;br /&gt;
local!scData.sgId&lt;br /&gt;
)&lt;br /&gt;
) &amp;gt; 1,&lt;br /&gt;
count(&lt;br /&gt;
whereContains(&lt;br /&gt;
ri!Data[ri!index].mtId,&lt;br /&gt;
index(index(ri!Data,whereContains(&lt;br /&gt;
ri!Data[ri!index].sgId,&lt;br /&gt;
local!scData.sgId&lt;br /&gt;
)),&lt;br /&gt;
&amp;quot;mtId&amp;quot;,&lt;br /&gt;
{}&lt;br /&gt;
)&lt;br /&gt;
)&lt;br /&gt;
)&amp;gt;1,&lt;br /&gt;
&amp;quot;Duplicate Combination &amp;quot;,&lt;br /&gt;
{}&lt;br /&gt;
)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to count frequency of data in dataset</title><link>https://community.appian.com/thread/59533?ContentTypeID=1</link><pubDate>Fri, 24 Aug 2018 12:11:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4313e688-bc33-4a5a-8f90-55fe8886f4fa</guid><dc:creator>sauravk</dc:creator><description>&lt;p&gt;I applied this approach. But i got to know one knew issue in this approach. As per requirement. I need to match combination of two columns in one dataset . But when i am trying to put this condition its checking count correct but not at horizontal level its checking vertical level. I mean if i have data like &lt;br /&gt; &lt;br /&gt; B 1 &lt;br /&gt; B 2 &lt;br /&gt; C 3 &lt;br /&gt; D 2 &lt;br /&gt; B 3&lt;br /&gt; &lt;br /&gt; In this case its showing error for row 2 (B 2). because count of both is more than one irrespective of any row. But our requirement is to check this combination at row level and it should give use count of that.&lt;br /&gt; &lt;br /&gt; Can you help me in that. I am sharing code snipped which i written on basis of your approach.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; validations: {&lt;br /&gt; if(or(rule!APN_isBlank(ri!Data[ri!index].sgId),rule!APN_isBlank(ri!Data[ri!index].mtId)),{},if(&lt;br /&gt; and(&lt;br /&gt; count(&lt;br /&gt; whereContains(&lt;br /&gt; ri!Data[ri!index].sgId,&lt;br /&gt; local!scData.sgId&lt;br /&gt; )&lt;br /&gt; ) &amp;gt; 1,&lt;br /&gt; count(&lt;br /&gt; whereContains(&lt;br /&gt; ri!Data[ri!index].mtId,&lt;br /&gt; local!scData.mtId&lt;br /&gt; )&lt;br /&gt; ) &amp;gt; 1&lt;br /&gt; ),&lt;br /&gt; &amp;quot;Duplicate Combination &amp;quot;,&lt;br /&gt; {}&lt;br /&gt; ))&lt;br /&gt; }&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to count frequency of data in dataset</title><link>https://community.appian.com/thread/59377?ContentTypeID=1</link><pubDate>Tue, 21 Aug 2018 07:49:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:29975b62-837d-48fb-b45a-92d5efffae11</guid><dc:creator>sauravk</dc:creator><description>Thanks a lot. Very simple &amp;amp; neat solution for this problem.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to count frequency of data in dataset</title><link>https://community.appian.com/thread/59323?ContentTypeID=1</link><pubDate>Mon, 20 Aug 2018 06:37:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b4cd6db4-3cb2-4761-b2a3-fc6ff42a0801</guid><dc:creator>mayurm168</dc:creator><description>1.	Let&amp;#39;s name the master data you have as coreData having 3 columns (col1,col2,col3)&lt;br /&gt;
2.	Create an expression rule named filterData which accepts input of cdt type of coreData (NO MULTIPLE)&lt;br /&gt;
	Code for the rule...&lt;br /&gt;
	if(&lt;br /&gt;
		rule!apn_isEmpty(ri!input),&lt;br /&gt;
		null,&lt;br /&gt;
		if(&lt;br /&gt;
			ri!input.col1=ri!input.col2,&lt;br /&gt;
			null,&lt;br /&gt;
			ri!input&lt;br /&gt;
		)&lt;br /&gt;
	)&lt;br /&gt;
3.  To use this rule you can use a!foreach but you need to filter out null from the output&lt;br /&gt;
	Code for the same...&lt;br /&gt;
	filter(&lt;br /&gt;
		fn!isnull,&lt;br /&gt;
		a!foreach(expression:rule!filerData, input:ri!coreData)	&lt;br /&gt;
	)&lt;br /&gt;
	&lt;br /&gt;
	Above rule will return coreData without rows that you don&amp;#39;t expect and it will also NOT have null values.&lt;br /&gt;
	You can use above output as source for todatasubset function and can show it in grid.&lt;br /&gt;
	&lt;br /&gt;
Hope this will be helpful!&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to count frequency of data in dataset</title><link>https://community.appian.com/thread/59307?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 16:59:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:83223c24-8cdb-4cfc-bfb8-e506cc7b0014</guid><dc:creator>ankita0004</dc:creator><description>For this, You can apply the validation at field level&lt;br /&gt;
&lt;br /&gt;
like for column 1&lt;br /&gt;
&lt;br /&gt;
a!gridRowLayout(&lt;br /&gt;
contents:{&lt;br /&gt;
a!textField(&lt;br /&gt;
label:&amp;quot;Column 1&amp;quot;,&lt;br /&gt;
value:ri!data[ri!index].c1,&lt;br /&gt;
saveInto:ri!data[ri!index].c1,&lt;br /&gt;
validations:{&lt;br /&gt;
if(&lt;br /&gt;
count(&lt;br /&gt;
whereContains(&lt;br /&gt;
ri!data[ri!index].c1,&lt;br /&gt;
ri!data.c1&lt;br /&gt;
)&lt;br /&gt;
)&amp;gt;1,&lt;br /&gt;
&amp;quot;Data is duplicate&amp;quot;,&lt;br /&gt;
{}&lt;br /&gt;
)&lt;br /&gt;
}&lt;br /&gt;
)&lt;br /&gt;
}&lt;br /&gt;
)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to count frequency of data in dataset</title><link>https://community.appian.com/thread/59299?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 14:39:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fa985f58-0103-4f88-b4c2-f0bd59eb4b8d</guid><dc:creator>Carlos Santander</dc:creator><description>Ok, so you can use the expression I provided earlier as a starting point&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to count frequency of data in dataset</title><link>https://community.appian.com/thread/59294?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 13:51:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4cbb723c-0a7f-4e1c-a5da-b96d359f42c5</guid><dc:creator>sauravk</dc:creator><description>&lt;p&gt;Thanks for the inputs.&lt;/p&gt;
&lt;p&gt;Basically we are having a full dataset which i am passing to another rule after applying some filters on UI. Then further back same data is getting append in main dataset and going to DB for CRUD operation. My intention is to do this validation on grid page itself by using same master data set or sub data set which we are populating on grid. I know this validation would be costly with DB hit so i am trying to save that approach only. So i want to put validation and mark it red if we select same combination in that grid.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to count frequency of data in dataset</title><link>https://community.appian.com/thread/59292?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 13:27:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:189925d8-3ba8-4750-b3a6-eee76c6b17f5</guid><dc:creator>Carlos Santander</dc:creator><description>&lt;p&gt;I&amp;#39;m assuming you mean this is a grid that is presented to the user and not data that&amp;#39;s coming from the database. While there&amp;#39;s no out-of-the-box rule that will give you this, the following expression can serve as a starting point:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;= load(
  local!data: {
    { c1: &amp;quot;A&amp;quot;, c2: &amp;quot;B&amp;quot;, c3: &amp;quot;C&amp;quot; },
    { c1: &amp;quot;A&amp;quot;, c2: &amp;quot;B&amp;quot;, c3: &amp;quot;D&amp;quot; },
    { c1: &amp;quot;C&amp;quot;, c2: &amp;quot;B&amp;quot;, c3: &amp;quot;E&amp;quot; },
    { c1: &amp;quot;C&amp;quot;, c2: &amp;quot;A&amp;quot;, c3: &amp;quot;F&amp;quot; },
    { c1: &amp;quot;C&amp;quot;, c2: &amp;quot;G&amp;quot;, c3: &amp;quot;H&amp;quot; }
  },
  
  a!foreach(
    items: local!data,
    expression: with(
      difference(
        intersection(
          wherecontains(property(fv!item, &amp;quot;c1&amp;quot;, null), property(local!data, &amp;quot;c1&amp;quot;, null)),
          wherecontains(property(fv!item, &amp;quot;c2&amp;quot;, null), property(local!data, &amp;quot;c2&amp;quot;, null))
        ),
        fv!index
      )
    )
  )
)
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This expression returns an array containing the rows that contain the same keys (in your case, c1 and c2), and an empty array if there are no matching rows at that index. It probably won&amp;#39;t scale very well, so please keep an eye on performance for your specific data sets.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re trying to check this for data that&amp;#39;s already in the database, I would suggest you do this in the database server and not in Appian.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>