<?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 get certain object based on Max value.</title><link>https://community.appian.com/discussions/f/data/21705/how-to-get-certain-object-based-on-max-value</link><description>I have data that is not fetched from DB. 
 The Data is in this format: 
 List of Dictionary - 2 items 
 
 
 Dictionary 
 
 
 id - 1 (Number (Integer)) 
 
 
 Max_days - 54 (Number (Integer)) 
 
 
 Max_amount - 36671 (Number (Integer)) 
 
 
 
 
 Dictionary</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to get certain object based on Max value.</title><link>https://community.appian.com/thread/84888?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 16:38:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3a91684c-0e34-49ed-9ff0-e085cc40e849</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Ah yes, batchSize -1 is definitely not necessary, &amp;quot;1&amp;quot; will work correctly there.&amp;nbsp; I would still recommend indexing however as to return a single dictionary vs a list of dictionary with 1 item, just incase :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get certain object based on Max value.</title><link>https://community.appian.com/thread/84886?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 16:13:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5bd486a3-00d8-4352-a049-3cb95056abde</guid><dc:creator>Aparajita Singh</dc:creator><description>&lt;p&gt;I agree with Stefan and Chris! You can even give batchSize as 1 in which case the need for indexing will also be eliminated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get certain object based on Max value.</title><link>https://community.appian.com/thread/84882?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 15:12:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5ac3e9ea-c1a5-4803-b620-c508b925d0e8</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Agree with Stefan, utilize todatasubset() and sort by Max_days, return the top item only:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!data: {
    {id: 1, Max_days: 54, Max_amount: 36671},
    {id: 2, Max_days: 1317, Max_amount: 15158},
    {id: 3, Max_days: 99, Max_amount: 12545},
    {id: 4, Max_days: 200, Max_amount: 54321}
  },
  
  index(
    todatasubset(local!data,a!pagingInfo(1,-1,a!sortInfo(&amp;quot;Max_days&amp;quot;,false))).data,
    1,
    null
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get certain object based on Max value.</title><link>https://community.appian.com/thread/84878?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 13:21:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:da1870d5-8674-40fc-9e0a-1ed28c05046d</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;You can use todatasubset() to sort lists of dictionaries.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get certain object based on Max value.</title><link>https://community.appian.com/thread/84875?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 12:45:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:35929cd9-78ff-4e23-ae26-c520172fb825</guid><dc:creator>Darko</dc:creator><description>&lt;p&gt;Also to mention this should not be the solution for just these 2 objects as I can have a list of N objects. So the one with the highest Max_days should be returned. Thx&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>