{"id":28012,"date":"2017-06-16T15:07:07","date_gmt":"2017-06-16T07:07:07","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=28012"},"modified":"2024-01-17T10:48:04","modified_gmt":"2024-01-17T02:48:04","slug":"numbertostate","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/numbertostate\/","title":{"rendered":"NumberToState()"},"content":{"rendered":"\n<h2>Format<\/h2>\n<p class=\"intro-text\"><strong>NumberToState(DigitalStateValues [,Datasource] [,DigitalStateSet])<\/strong><\/p>\n<h2>Returns<\/h2>\n<p class=\"intro-text\">Returns the name of the digital state that corresponds to the provided digital state value.<\/p>\n<h2>Inputs<\/h2>\n<p class=\"intro-text\"><b>DigitalStateValues: <\/b>The values of the digital states which should be converted to their respective names. If you have a tag that returns a collection of digital state values, you can supply the tag name here, using tag syntax (i.e. <span class=\"code-fragment\">{tagname}<\/span>)<br \/>\nBehaviour: Required<br \/>\nDimensions: Collection, SingleValue, MultiCollection<br \/>\nValid data types: Integer<\/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 <em>DigitalStateSet<\/em> parameter must also be specified.\u00a0Use <em>null<\/em> if 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-p2blue\">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 state values to names.<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\">NumberToState(1, null, 'OnOffStates')<\/span><br \/>\nResult: Returns 'ON' if the assigned name of digital state 1 is 'ON' in the digital state set called 'OnOffStates'.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">NumberToState({Tag1})<\/span><br \/>\nResult: Returns the name of every digital state value that {Tag1} returned during the fetch, using the digital state set which is assigned to {Tag1}. Note: This will only work if <em>Tag1<\/em> has a digital state set assigned,<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">NumberToState({Tag1}, '', 'OnOffStates')<\/span><br \/>\nResult: Returns the name of every digital state value that {Tag1} returned during the fetch using the 'OnOffStates' digital state set. Note: Because the 2nd and 3rd parameter are specified, the function ignores whatever is assigned to the tag and will instead use the digital state set provided.<\/p>\n<p class=\"left-bar\">Tip: If you have access to the sample data, try running the following examples using the <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\">NumberToState(0, \"Oil and Gas Data\", \"On Off\")<\/span><br \/>\nResult: <span style=\"color: #0000ff;\">Off\u00a0<\/span><\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">NumberToState(0, null, \"Status\")<\/span><br \/>\nResult: <span style=\"color: #0000ff;\">Online\u00a0<\/span><\/p>\n<h2><span id=\"Release_History\">Release History<\/span><\/h2>\n<ul class=\"intro-text\">\n<li>NumberToState() 4.6.5\n<ul class=\"intro-text\">\n<li>Changed DigitalStateValues parameter to support MultiCollection values.<\/li>\n<\/ul>\n<\/li>\n<li>NumberToState() 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 numeric values that are mapped to state text strings.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/numbertostate\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":28080,"parent":3650,"menu_order":147,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100],"class_list":["post-28012","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\/28012","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=28012"}],"version-history":[{"count":4,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28012\/revisions"}],"predecessor-version":[{"id":64749,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28012\/revisions\/64749"}],"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\/28080"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=28012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=28012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=28012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}