<?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>Using If with {}</title><link>https://community.appian.com/discussions/f/rules/17985/using-if-with</link><description>Hey everyone I&amp;#39;m trying to use an IF statement to return TRUE if an account is one of 2 types and in shortfall using 
 =if(ri!portfolio&amp;lt;&amp;gt;{&amp;quot;type1&amp;quot;,&amp;quot;type2&amp;quot;},false,if(trim(ri!arrearsStatus)=&amp;quot;Shortfall&amp;quot;,true(),false())) 
 but if I pass type1 and Shortfall</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Using If with {}</title><link>https://community.appian.com/thread/70768?ContentTypeID=1</link><pubDate>Mon, 02 Dec 2019 12:16:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:877dbbe8-2b73-4672-bc58-9f6dca435d01</guid><dc:creator>PhilB</dc:creator><description>&lt;p&gt;I would like to clarify what is happening here, as there are a couple of things going on.&lt;/p&gt;
&lt;p&gt;First, operators can handle lists. For example, {1, 2, 3, 4, 5) &amp;gt; 3 will return {false, false, false, true, true} as the &amp;gt; operator will compare 3 to every item within the list. in your example,&amp;nbsp;&lt;span&gt;ri!portfolio is compared to every item in&amp;nbsp;&lt;span&gt;{&amp;quot;type1&amp;quot;,&amp;quot;type2&amp;quot;} and so you end up with a list containing two booleans - for example {false, true} where ri!portfolio is &amp;quot;type1&amp;quot;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Second, and following on from this, if() can &lt;em&gt;also&lt;/em&gt; handle lists!&amp;nbsp;This is &lt;a href="https://docs.appian.com/suite/help/19.4/fnc_logical_if.html"&gt;documented&lt;/a&gt;, but if() will iterate over each item in the array it is passed and if the item is true, return the result of its 2nd parameter, or the result of the 3rd parameter if the item is false. Note that the second and third&amp;nbsp;parameters in your example are not lists, so one or the other is returned depending on the state of the item. If your 2nd and 3rd parameters were lists, if() would return the appropriate item in each list depending on the state of the item - for example,&amp;nbsp;if({true, false, true}, {&amp;quot;a&amp;quot;,&amp;quot;b&amp;quot;, &amp;quot;c&amp;quot;}, {1, 2, 3}) will return&amp;nbsp;{&amp;quot;a&amp;quot;, 2, &amp;quot;c&amp;quot;}.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Finally, your nested if()&amp;nbsp; - specifically if(trim(ri!arrearsStatus)=&amp;quot;Shortfall&amp;quot;,true(),false()) - is entirely unnecessary. I see this a lot, but if you ever write if(condition, true, false) then DON&amp;#39;T!&amp;nbsp;&lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&amp;nbsp;Ultimately&amp;nbsp;a condition for an if() should always return a boolean, so returning booleans as both the 2nd and 3rd parameters shouldn&amp;#39;t ever be required. Additionally, if you need to reverse the result of the condition, just use not().&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Ultimately your expression should be:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;if(
  contains(
    {&amp;quot;type1&amp;quot;, &amp;quot;type2&amp;quot;},
    ri!portfolio
  ),
  trim(
    ri!arrearsStatus
  ) = &amp;quot;Shortfall&amp;quot;,
  false
)&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using If with {}</title><link>https://community.appian.com/thread/70767?ContentTypeID=1</link><pubDate>Mon, 02 Dec 2019 11:44:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:932b29e3-c4d4-4933-ad08-527f8602bf60</guid><dc:creator>vinayr214137</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;You are trying to compare list with single object, use contains&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if(
  not(contains(touniformstring({&amp;quot;type1&amp;quot;,&amp;quot;type2&amp;quot;}),ri!portfolio)),
   false,
   if(
     trim(ri!arrearsStatus)=&amp;quot;Shortfall&amp;quot;,
       true(),
       false()
    )
)

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using If with {}</title><link>https://community.appian.com/thread/70766?ContentTypeID=1</link><pubDate>Mon, 02 Dec 2019 11:44:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d13c5e28-23ee-42bd-adae-af46b05a2c59</guid><dc:creator>SerenRhys</dc:creator><description>&lt;p&gt;Thank you so much Krishna :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using If with {}</title><link>https://community.appian.com/thread/70765?ContentTypeID=1</link><pubDate>Mon, 02 Dec 2019 11:42:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e965ff51-d816-447f-89b2-a656d757b642</guid><dc:creator>Krishna Chaitanya Mallavarapu</dc:creator><description>&lt;p&gt;if(&lt;br /&gt; or(&lt;br /&gt; ri!portfolio = &amp;quot;type1&amp;quot;,&lt;br /&gt; ri!portfolio = &amp;quot;type2&amp;quot;&lt;br /&gt; ),&lt;br /&gt; if(&lt;br /&gt; trim(&lt;br /&gt; ri!arrearsStatus&lt;br /&gt; ) = &amp;quot;Shortfall&amp;quot;,&lt;br /&gt; true(),&lt;br /&gt; false()&lt;br /&gt; ),&lt;br /&gt; false()&lt;br /&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>