{"id":28013,"date":"2017-06-16T15:05:58","date_gmt":"2017-06-16T07:05:58","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=28013"},"modified":"2024-08-15T10:31:31","modified_gmt":"2024-08-15T02:31:31","slug":"statetonumber","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/statetonumber\/","title":{"rendered":"StateToNumber()"},"content":{"rendered":"\n<h2>Format<\/h2>\n<p class=\"intro-text\"><strong>StateToNumber(DigitalStateNames [,Datasource] [,DigitalStateSet])<\/strong><\/p>\n<h2>Returns<\/h2>\n<p class=\"intro-text\">Returns the number value of the digital state that corresponds to the provided digital state text value.<\/p>\n<h2>Inputs<\/h2>\n<p class=\"intro-text\"><b>DigitalStateNames: <\/b>The name of the digital states which should be converted to their respective values.\u00a0If you have a tag that returns a collection of digital state names, you can supply the tag name here, using tag syntax (i.e.\u00a0<span class=\"code-fragment\">{tagname}<\/span>).<br \/>\nBehaviour: Required<br \/>\nDimensions: Collection, SingleValue, MultiCollection<br \/>\nValid data types: String<\/p>\n<p class=\"intro-text\"><b>Datasource: <\/b>Optional. Name of the datasource to which the digital state set belongs. If this parameter is supplied then the\u00a0<em>DigitalStateSet<\/em>\u00a0parameter must also be specified.\u00a0Use\u00a0<em>null<\/em>\u00a0if the digital state set is not assigned to a datasource.\u00a0<br \/>\nBehaviour: Optional<br \/>\nDimensions: SingleValue<br \/>\nValid data types: Null, String<\/p>\n<p class=\"left-bar\">Note: The 2nd\u00a0and 3rd parameters are used to correctly identify the digital state set for the function. They are usually needed because:<br \/>\n- A manually created digital state set might not be imported by an adaptor; in such cases it might not have a datasource.<br \/>\n- It\u2019s possible that multiple datasources\/adaptors import different digital state sets with the same name. E.g. \u201cOn Off\u201d is quite common.<\/p>\n<p class=\"intro-text\"><b>DigitalStateSet: <\/b>Optional. Name of the digital state set which should be used for converting digital states to values.<br \/>\nBehaviour: Optional<br \/>\nDimensions: SingleValue<br \/>\nValid data types: String<\/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: <span class=\"code-fragment\">StateToNumber('ON', null, 'OnOffStates')<\/span><br \/>\nResult: Returns 1 if the assigned value of digital state 'ON' is 1 in the digital state set called 'OnOffStates'.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">StateToNumber({Tag1})<\/span><br \/>\nResult: Returns the value of every digital state name that {Tag1} returned during the fetch using the digital state set which is assigned to {Tag1}.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">StateToNumber({Tag1}, '', 'OnOffStates')<\/span><br \/>\nResult: Returns the value of every digital state name that {Tag1} returned during the fetch using the 'OnOffStates' digital state set.<\/p>\n<p class=\"left-bar\">Tip: If you have access to the sample data, try running the following examples using the\u00a0<a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/configuring-your-system\/creating-a-calculation\/using-the-calculation-tester\/\">calculation tester<\/a>.\u00a0<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">StateToNumber(\"On\", \"Oil and Gas Data\", \"On Off\")<\/span><br \/>\nResult: 1\u00a0<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">StateToNumber(\"Online\", null, \"Status\")<\/span><br \/>\nResult: 0\u00a0<\/p>\n<h2><span id=\"Release_History\">Release History<\/span><\/h2>\n<ul class=\"intro-text\">\n<li>StateToNumber() 4.6.5\n<ul class=\"intro-text\">\n<li>Changed DigitalStateNames parameter to support MultiCollection values.<\/li>\n<\/ul>\n<\/li>\n<li>StateToNumber() 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 state text strings that are mapped to numeric values.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/statetonumber\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":28088,"parent":3650,"menu_order":195,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100],"class_list":["post-28013","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\/28013","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=28013"}],"version-history":[{"count":2,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28013\/revisions"}],"predecessor-version":[{"id":64767,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28013\/revisions\/64767"}],"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\/28088"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=28013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=28013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=28013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}