<?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 find the max no from an array without using Max() ?</title><link>https://community.appian.com/discussions/f/new-to-appian/25533/how-to-find-the-max-no-from-an-array-without-using-max</link><description>Hi dear, 
 I have written code like in the picture, I just want to print the max no without using max function.</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99642?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 15:35:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f1f27b11-7283-4f80-ba95-fdaeca2ef6c9</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;That works too, though at that point you may as well sort and get the 1st index (especially since setting it up that way from the start enables you to potentially add other sort factors, like if one is needed to break a tie).&amp;nbsp; Also I find displayValue() to be unnecessarily messy-looking in most cases, though it is handy in a few.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99641?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 15:34:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2fb04ffe-7e7d-4ccb-b214-1cab4b2a2394</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;I love displayValue().&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!data: {
    &amp;#39;type!{urn:com:gdit:types}COE_Sample_CDT&amp;#39;(step: 2, requestByName: &amp;quot;Mike&amp;quot;),
    &amp;#39;type!{urn:com:gdit:types}COE_Sample_CDT&amp;#39;(step: 3, requestByName: &amp;quot;Harshit&amp;quot;),
    &amp;#39;type!{urn:com:gdit:types}COE_Sample_CDT&amp;#39;(step: 1, requestByName: &amp;quot;Chris&amp;quot;),
    &amp;#39;type!{urn:com:gdit:types}COE_Sample_CDT&amp;#39;(step: 4, requestByName: &amp;quot;Stefan&amp;quot;)
  },
  
  displayValue(
    max(local!data.step),
    local!data.step,
    local!data.requestByName,
    null
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99640?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 15:27:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b6769463-87b4-45fe-8133-e3ac130b7dd5</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Using max() with displayValue()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99639?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 15:12:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3eed3426-aec2-4605-a331-b8c114917b0c</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;max() is fairly useless in, let&amp;#39;s say, the case of having an array of CDT and wanting to find the element in the array with the max value on a particular element - in which case, the &amp;quot;todatasubset&amp;quot; sorting method listed above works pretty well overall.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99638?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 15:06:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fc1a04b8-c643-4396-bc8e-5c5fca6456c8</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Hi &lt;a href="/members/shukurs0001"&gt;shukurs0001&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;I want to understand your use case. Why do you want to do it without the max() function? Tho there are multiple ways of doing it, max() will be the most efficient way (as Chris also mentioned)&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99636?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 14:50:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:760b9f52-3e7e-4d57-aded-116530ba9dde</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;You could do this with looping, but max() is by far the easiest and fastest method.&amp;nbsp; I would also be interested in the use case reasoning to avoid max().&lt;/p&gt;
&lt;p&gt;deepakg&amp;#39;s example with todatasubset() sorting is a commonly used solution for similar items as well.&lt;/p&gt;
&lt;p&gt;Additionally, max value from nested a!forEach():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!list: {1,3,8,6,5,2},
  
  index(
    reject(
      fn!isnull,
      a!forEach(
        items: local!list,
        expression: {
          a!localVariables(
            local!item: fv!item,
            if(
              count(
                wherecontains(
                  true,
                  a!forEach(
                    items: local!list,
                    expression: toboolean(fv!item&amp;lt;local!item)
                  )
                )
              )=count(local!list)-1,
              fv!item,
              null
            )
          )
        }
      )
    ),
    1,
    null
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Max with sortintegerarray():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;index(
  sortintegerarray({1,3,8,6,5},true),
  1,
  null
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99588?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 04:03:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5d479ddf-c312-468e-ad36-b8283ea90cce</guid><dc:creator>deepakg271869</dc:creator><description>&lt;p&gt;where you are looking for looping and why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99587?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 04:03:09 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:65c1e06b-86d4-4502-97a5-2fad7ee018f5</guid><dc:creator>shukurs0001</dc:creator><description>&lt;p&gt;Can&amp;#39;t we achieve this by looping?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the max no from an array without using Max() ?</title><link>https://community.appian.com/thread/99585?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 03:53:43 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2e2210ad-e604-461c-8908-a78ebf921974</guid><dc:creator>deepakg271869</dc:creator><description>&lt;p&gt;You can create a local variable of Map type and use to data subset to sort the array descending and get the 1st index value&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!listOfInts: {
    a!map(num: 5),
    a!map(num: 6),
    a!map(num: 2),
    a!map(num: 1),
    a!map(num: 10),
    a!map(num: 7)
  },
  index(
    index(
      todatasubset(
        local!listOfInts,
        a!pagingInfo(1, - 1, a!sortInfo(&amp;quot;num&amp;quot;, false()))
      ).data,
      &amp;quot;num&amp;quot;,
      {}
    ),
    1,
    {}
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>