{"id":16321,"date":"2016-06-30T09:26:48","date_gmt":"2016-06-30T01:26:48","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=16321"},"modified":"2024-08-15T10:31:31","modified_gmt":"2024-08-15T02:31:31","slug":"singlevalueif","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/singlevalueif\/","title":{"rendered":"SingleValueIf()"},"content":{"rendered":"\n<h2><span id=\"Format\">Format<\/span><\/h2>\n<p class=\"intro-text\"><strong>SingleValueIf(Condition ,ValueIfTrue ,ValueIfFalse)<\/strong><\/p>\n<h2><span id=\"Returns\">Returns<\/span><\/h2>\n<p class=\"intro-text\">Returns the value of the <strong>ValueIfTrue\u00a0<\/strong>expression if\u00a0the <strong>Condition\u00a0<\/strong>expression evaluates to true. Otherwise, returns the value of the <strong>ValueIfFalse\u00a0<\/strong>expression.\u00a0<\/p>\n<p class=\"left-bar-p2blue\">See also: <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/if\/\">If()<\/a><\/p>\n<h2><span id=\"Parameters\">Inputs<\/span><\/h2>\n<p class=\"intro-text\"><strong>Condition<\/strong>: The\u00a0expression to be evaluated.<br \/>\nBehaviour: Required<br \/>\nDimension:\u00a0Collection, SingleValue<br \/>\nValid\u00a0data types:\u00a0Boolean<\/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 \/>\nFor 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>: The value returned if the condition evaluates to true.<br \/>\nBehaviour: Required <br \/>\nDimension: Error, Collection, SingleValue, Matrix, MultiCollection<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration, Error<\/p>\n<p class=\"intro-text\"><strong>ValueIfFalse<\/strong>: The value returned if the condition evaluates to false.<br \/>\nBehaviour: Required\u00a0<br \/>\nDimension: Error, Collection, SingleValue, Matrix, MultiCollection<br \/>\nValid 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\">If a collection is used for the condition, it must contain only\u00a01 value. If the condition is a collection which contains 0 or more than 1 value, the function will return an error.<\/p>\n<h2>When to Use<\/h2>\n<p class=\"intro-text\">The SingleValueIf() function takes a single value and returns a value\u00a0which is either the true or false parameter, whereas <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/if\/\">If()<\/a> takes the individual values in the collections and compares them, returning a collection comprised of the individual evaluations.\u00a0<\/p>\n<p class=\"intro-text\">Here are some examples which show the difference:<\/p>\n<pre>If([1, 1, 2, 2]  \u00a0&gt;= 2, [5, 5, 5, 5], [2, 2, 2, 2]) = <strong>\u00a0[2, 2, 5, 5]<\/strong><\/pre>\n<pre>SingleValueIf([1] &gt;= 2, [5, 5, 5, 5], [2, 2, 2, 2]) = <strong>\u00a0[2, 2, 2, 2]<\/strong><\/pre>\n<pre>SingleValueIf([2] &gt;= 2, [5, 5, 5, 5], [2, 2, 2, 2]) = <strong>\u00a0[5, 5, 5, 5]<\/strong><\/pre>\n<p class=\"left-bar\"><strong>Note<\/strong>: The <em>ValueIfTrue <\/em>and <em>ValueIfFalse <\/em>parameters <strong>do <em>not<\/em> need to be of the same type<\/strong>, so you can use this function to return different data types depending on the outcome.<\/p>\n<h2><span id=\"Examples\">Examples<\/span><\/h2>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">SingleValueIf({tagname}&gt;=2,[5, 5, 5, 5], [2, 2, 2, 2])<\/span><br \/>\nResult: If the value of\u00a0{tagname} is greater than or equal to 2, return [5, 5, 5, 5]. Otherwise, return [2, 2, 2, 2].<br \/>\n<em>Example outcomes<\/em>: <br \/>\n\u00a0 \u00a0 \u00a0Where tagname\u00a0is\u00a0[1], the function returns [2, 2, 2, 2].<br \/>\n\u00a0 \u00a0 \u00a0Where tagname\u00a0is\u00a0[], the function returns an error, because the collection contains 0 values.<br \/>\n\u00a0 \u00a0 \u00a0Where tagname\u00a0is\u00a0[1,2,3], the function returns an error, because the collection contains more than 1 value.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">SingleValueIf({tagname}&gt;=0,{tagname},\"Too Low\")<\/span><br \/>\nResult: 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\u00a0<\/p>\n<h2><span id=\"Release_History\">Release History<\/span><\/h2>\n<ul class=\"intro-text\">\n<li>SingleValueIf() 4.6.5\n<ul class=\"intro-text\">\n<li>Changed ValueIfTrue and ValueIfFalse parameters to support MultiCollection values.<\/li>\n<\/ul>\n<\/li>\n<li>SingleValueIf() 4.0\n<ul class=\"intro-text\">\n<li>Initial version<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Use SingleValueIf() to take a single value and return either the true or false value, where the types of the true or false values do not have to match.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/singlevalueif\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":16334,"parent":3650,"menu_order":192,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100,364],"class_list":["post-16321","page","type-page","status-publish","has-post-thumbnail","hentry","category-tech-ref","tag-calculations","tag-if","Version-4-0","Version-4-6-5","Product-srv"],"_links":{"self":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/16321","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=16321"}],"version-history":[{"count":2,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/16321\/revisions"}],"predecessor-version":[{"id":64766,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/16321\/revisions\/64766"}],"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\/16334"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=16321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=16321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=16321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}