{"id":28035,"date":"2017-06-16T15:05:30","date_gmt":"2017-06-16T07:05:30","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=28035"},"modified":"2024-08-15T10:31:32","modified_gmt":"2024-08-15T02:31:32","slug":"switch","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/switch\/","title":{"rendered":"Switch()"},"content":{"rendered":"\n<h2>Format<\/h2>\n<p class=\"intro-text\"><strong>Switch(InputValues ,Case1Value ,Case1Result ,Case2Value ,Case2Result [,OtherCases])<\/strong><\/p>\n<h2>Returns<\/h2>\n<p class=\"intro-text\">Returns the replacement value for each input value based on which cases were matched for each individual input value.<\/p>\n<h2>Inputs<\/h2>\n<p class=\"intro-text\"><b>InputValues: <\/b>The input values that the function will compare to available cases and replace.<br \/>\nBehaviour: Required<br \/>\nDimensions: Collection, SingleValue, MultiCollection<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration<\/p>\n<p class=\"intro-text\"><b>Case1Value: <\/b>The value of the first case.<br \/>\nBehaviour: Required<br \/>\nDimensions: SingleValue<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration<\/p>\n<p class=\"intro-text\"><b>Case1Result: <\/b>The expression which will be (lazily) evaluated and used to replace the input value if it matched the value of this case.<br \/>\nBehaviour: Required<br \/>\nDimensions: SingleValue<br \/>\nValid data types: String<\/p>\n<p class=\"intro-text\"><b>Case2Value: <\/b>The value of the second case.<br \/>\nBehaviour: Required<br \/>\nDimensions: SingleValue<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration<\/p>\n<p class=\"intro-text\"><b>Case2Result: <\/b>The expression which will be (lazily) evaluated and used to replace the input value if it matched the value of this case.<br \/>\nBehaviour: Required<br \/>\nDimensions: SingleValue<br \/>\nValid data types: String<\/p>\n<p class=\"intro-text\"><b>OtherCases: <\/b>Subsequent cases must follow the existing pattern. I.e. even numbered parameters must contain possible values, odd numbered subsequent parameters must contain the expression which will be (lazily) evaluated and used to replace the input value.<br \/>\nBehaviour: ParamsArray<br \/>\nDimensions: SingleValue<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration<\/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>Examples<\/h2>\n<p class=\"intro-text\">Expression: Switch(1 + 1, 1, \"'case 1'\", 2, \"'case 2'\", 3, \"'case 3'\")<br \/>\nResult: Returns the string \"case 2\".<\/p>\n<p class=\"intro-text\">Expression: Switch({Tag1}, 1, \"{Tag2}\", 2, \"{Tag3}\", 3, \"{Tag4}\")<br \/>\nResult: Returns the last known value from {Tag2}, {Tag3} and {Tag4} for every 1, 2 or 3 value found in {Tag1}.<\/p>\n<h2><span id=\"Release_History\">Release History<\/span><\/h2>\n<ul class=\"intro-text\">\n<li>Switch() 4.6.5\n<ul class=\"intro-text\">\n<li>Changed InputValues parameter to support MultiCollection values.<\/li>\n<\/ul>\n<\/li>\n<li>Switch() 4.5.1\n<ul class=\"intro-text\">\n<li>Initial version<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Returns the replacement value for each input value based on which cases were matched for each individual input value.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/switch\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":28092,"parent":3650,"menu_order":210,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100],"class_list":["post-28035","page","type-page","status-publish","has-post-thumbnail","hentry","category-tech-ref","tag-calculations","Version-4-5-1","Version-4-6-5","Product-srv"],"_links":{"self":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28035","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=28035"}],"version-history":[{"count":2,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28035\/revisions"}],"predecessor-version":[{"id":64776,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28035\/revisions\/64776"}],"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\/28092"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=28035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=28035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=28035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}