{"id":9660,"date":"2016-02-22T09:05:58","date_gmt":"2016-02-22T01:05:58","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=9660"},"modified":"2024-01-17T10:48:02","modified_gmt":"2024-01-17T02:48:02","slug":"if","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/if\/","title":{"rendered":"If()"},"content":{"rendered":"\n<h2><span id=\"Format\">Format<\/span><\/h2>\n<p class=\"intro-text\"><strong>If(Condition ,ValueIfTrue ,ValueIfFalse)<\/strong><\/p>\n<h2><span id=\"Returns\">Returns<\/span><\/h2>\n<p class=\"intro-text\">Returns points in the <strong>ValueIfTrue\u00a0<\/strong>expression while the <strong>Condition\u00a0<\/strong>expression evaluates to non-zero (true). Otherwise, returns points in the <strong>ValueIfFalse\u00a0<\/strong>expression while the <strong>Condition \u00a0<\/strong>expression evaluates to zero (false).<\/p>\n<p class=\"left-bar-p2blue\">See also: <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/singlevalueif\/\">SingleValueIf()<\/a><\/p>\n<h2><span id=\"Parameters\">Inputs<\/span><\/h2>\n<p class=\"intro-text\"><strong>Condition<\/strong>: The\u00a0expression to be evaluated.<br \/>\n Behaviour: Required<br \/>\n Dimension:\u00a0Collection, SingleValue<br \/>\n Valid\u00a0data types:\u00a0Boolean, Decimal, Integer<\/p>\n<p class=\"left-bar-p2blue\"><strong>Note<\/strong>: Valid comparison operators are: <strong>==<\/strong>,<strong> !=<\/strong>,<strong> &lt;<\/strong>,<strong> &lt;=<\/strong>,<strong> &gt;<\/strong>,<strong> &gt;=<\/strong><br \/>\n For a full list of operators, see <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/operators\/\">Operators<\/a>.<\/p>\n<p class=\"intro-text\"><strong>ValueIfTrue<\/strong>: Can evaluate to either a number or a string, but it\u00a0must evaluate to the same type as <em>ValueIfFalse<\/em>.<br \/>\n Behaviour: Required <br \/>\n Dimension: Collection, SingleValue<br \/>\n Valid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration, Error<\/p>\n<p class=\"intro-text\"><strong>ValueIfFalse<\/strong>: Can evaluate to either a number or a string, but it\u00a0must evaluate to the same type as <em>ValueIfTrue<\/em>.<br \/>\n Behaviour: Required\u00a0<br \/>\n Dimension: Collection, SingleValue<br \/>\n Valid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration, Error<\/p>\n<p class=\"left-bar\"><a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/calculation-syntax\/#Data_Type\">How to format data types<\/a><\/p>\n<h2>Common Traps<\/h2>\n<p class=\"intro-text\"><em>ValueIfFalse\u00a0<\/em>must evaluate to the same type as <em>ValueIfTrue<\/em>. E.g. The following expression is not valid:<\/p>\n<p class=\"intro-text\"><span class=\"code-fragment\">If({tagname}&gt;=0,{tagname},\"Too Low\")<\/span><\/p>\n<p class=\"intro-text\">Expected result: If the value of\u00a0{tagname} is greater than or equal to zero, return the value of the tag. Otherwise, return the string \"Too Low\".<br \/>\n Actual result: This call\u00a0would fail because\u00a0{tagname} contains integer or decimal values and mixing those with a string is not allowed.<\/p>\n<h2><span id=\"Examples\">Examples<\/span><\/h2>\n<p class=\"intro-text\">Expression:\u00a0<span class=\"code-fragment\">If({tagname}&gt;=0,{tagname},-1)<\/span><br \/>\n Result: If the value of\u00a0{tagname} is greater than or equal to zero, return the value of the tag. Otherwise, return -1.<\/p>\n<p class=\"intro-text\">Expression:\u00a0<span class=\"code-fragment\">If({tagname}==0,{tagname},-1)<\/span><br \/>\n Result: If the value of\u00a0{tagname} is equal to zero, return the value of the tag. Otherwise, return -1.\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use If() to return an expression that depends on whether a condition is true or false.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/if\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":9662,"parent":3650,"menu_order":121,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100,364],"class_list":["post-9660","page","type-page","status-publish","has-post-thumbnail","hentry","category-tech-ref","tag-calculations","tag-if","Product-srv"],"_links":{"self":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/comments?post=9660"}],"version-history":[{"count":1,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9660\/revisions"}],"predecessor-version":[{"id":46220,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9660\/revisions\/46220"}],"up":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/3650"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media\/9662"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=9660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=9660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=9660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}