<?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>DataSubset &amp;amp; Rule Reference Question</title><link>https://community.appian.com/discussions/f/best-practices/39784/datasubset-rule-reference-question</link><description>Hi Team, 
 I had 2 simple questions which I wanted to post here. Please help me if anyone has the answers : 
 
 Context : 
 You are given a list of CDT / Dictionary / Map with a few fields, eg : 
 
 Problem statement : 
 Get those CDTs which have key</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: DataSubset &amp; Rule Reference Question</title><link>https://community.appian.com/thread/151773?ContentTypeID=1</link><pubDate>Fri, 26 Sep 2025 12:16:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:53dde15f-0cb0-4092-aefa-b59219406d0b</guid><dc:creator>Shubham Aware</dc:creator><description>[quote userid="169852" url="~/discussions/f/best-practices/39784/datasubset-rule-reference-question"]Now for the approach 1, I had a question : how do I filter this custom data subset ? because I only see queryEntity and queryRecord but nothing to query this custom dataset&amp;nbsp;[/quote]
&lt;p&gt;You cannot filter a custom DataSubset directly; queryEntity/queryRecord work only on database/record entities.&lt;/p&gt;
[quote userid="169852" url="~/discussions/f/best-practices/39784/datasubset-rule-reference-question"]For approach 2 : is there a way we can eliminate the need of creating a different rule in the env and somehow use some function .. is it possible to create local functions in appian ? something like :&amp;nbsp;[/quote]
&lt;p&gt;Does not support local or anonymous functions; separate expression rules are required for reusable logic.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Recommend,&amp;nbsp;Use inline filter expressions with conditions or separate rules to filter lists efficiently.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DataSubset &amp; Rule Reference Question</title><link>https://community.appian.com/thread/151771?ContentTypeID=1</link><pubDate>Fri, 26 Sep 2025 11:56:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0dd7750e-ae65-4710-9ba7-4cae3904f533</guid><dc:creator>Harsha Sharma</dc:creator><description>&lt;p&gt;Given its a dictionary/map then you would need to write it to database so that filtering can be done for approach 1. Personally as per my understanding of the usecase its too much hassle so simpler way is foreach. If you are expecting a large dataset (which is not mentioned in description) then I would go for involving database and approach 1.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Anyway to answer your questions:&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp;&lt;/p&gt;
[quote userid="169852" url="~/discussions/f/best-practices/39784/datasubset-rule-reference-question"] how do I filter this custom data subset ? because I only see queryEntity and queryRecord but nothing to query this custom dataset&amp;nbsp;[/quote]
&lt;p&gt;To filter you need to store data into database using CDT or records. Then you can query the dataset.&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp;&lt;/p&gt;
[quote userid="169852" url="~/discussions/f/best-practices/39784/datasubset-rule-reference-question"]is there a way we can eliminate the need of creating a different rule in the env and somehow use some function .. is it possible to create local functions in appian ? something like[/quote]
&lt;p&gt;filter() needs a predicate so you need to have a rule/function which can be called here. We cannot create local functions as you are expecting!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DataSubset &amp; Rule Reference Question</title><link>https://community.appian.com/thread/151770?ContentTypeID=1</link><pubDate>Fri, 26 Sep 2025 11:53:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8916266f-ab55-466d-a9d1-af18f335dd30</guid><dc:creator>GautamShenoy</dc:creator><description>&lt;p&gt;Why doesn&amp;#39;t approach 1 make sense ? Think in terms of DB, if I could have a simple queryFilter return the dataset why not ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For the solution you provided in foreach : I didnt want to use this solution,&amp;nbsp;hence was looking for alternatives&lt;/p&gt;
&lt;p&gt;Thanks though&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DataSubset &amp; Rule Reference Question</title><link>https://community.appian.com/thread/151769?ContentTypeID=1</link><pubDate>Fri, 26 Sep 2025 11:45:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:38b43ed1-e7e4-4964-ba7d-9dc181c186e2</guid><dc:creator>Harsha Sharma</dc:creator><description>&lt;p&gt;Approach 1 doesnt make much sense according for me. For approach 2 whatever you will do in the expression you can do in the main rule itself by using a foreach(). Can you try something like this?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!map: {
    a!map(key: 12, val: &amp;quot;ABC&amp;quot;),
    a!map(key: 20, val: &amp;quot;DEF&amp;quot;),
    a!map(key: 30, val: &amp;quot;GHI&amp;quot;)
  },
  a!foreach(
    local!map,
    if(
      and(fv!item.key &amp;gt; 10, fv!item.key &amp;lt; 25),
      fv!item,
      {}
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>