{"id":9464,"date":"2016-02-18T09:25:00","date_gmt":"2016-02-18T01:25:00","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=9464"},"modified":"2024-07-04T16:10:42","modified_gmt":"2024-07-04T08:10:42","slug":"evalexp","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/evalexp\/","title":{"rendered":"EvalExp()"},"content":{"rendered":"\n<h2>Format<\/h2>\n<p class=\"intro-text\"><strong>EvalExp(Expr [, ParamsArray])<\/strong><\/p>\n<h2>Returns<\/h2>\n<p class=\"intro-text\">Evaluates the specified expression.\u00a0Optionally it can also override the value of <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/calculation-syntax\/#Context_Parameters\">context parameters<\/a> for the duration of the evaluation.<\/p>\n<p class=\"intro-text\">Behaves in exactly the same way as the Eval() function, except that the first parameter\u2019s type is <em>expression<\/em> and not a single value string.\u00a0<\/p>\n<p class=\"left-bar-yellow\"><strong>Use caution when nesting the EvalExp() functions, as they can quickly become complicated and difficult to troubleshoot.<\/strong><\/p>\n<h2>Inputs<\/h2>\n<p class=\"intro-text\"><strong>Expr<\/strong>: The expression to be evaluated.<br \/>\nBehaviour: Required<br \/>\nDimension: Expression, MultiCollection<br \/>\nValid data types: Expression<\/p>\n<p class=\"intro-text\"><strong>ParamsArray<\/strong>: The context parameters to be used to override the default context parameters of the expression.<br \/>\nBehaviour: Optional [0..n]<br \/>\nDimension: Collection, SingleValue, Matrix, MultiCollection<br \/>\nValid data\u00a0types: Null, Boolean, DateTime, Decimal, Integer, String, Duration, Error<\/p>\n<p class=\"intro-text\">Note:\u00a0These parameters must be specified in pairs. The first parameter must be the name of an expression context parameter and the second parameter must be the value of it. <br \/>\nE.g. <span class=\"code-fragment\">EvalExp({myTag}, \"sampleMethod\", \"Raw\")<\/span>. This will evaluate the {myTag} expression with the sample method set to \"Raw\" in the expression context.\u00a0Note the use of {} around the tag name.<\/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>When to use<\/h2>\n<p class=\"intro-text\">Both Eval() and EvalExp() can be used for evaluating expressions with overridden context parameters.\u00a0The difference is that the first parameter of Eval() is a string while the first parameter of EvalExp() is an expression.<\/p>\n<p class=\"intro-text\">Here is an example showing the difference (without using context parameters, for simplicity):<\/p>\n<p class=\"intro-text\"><span class=\"code-fragment\">Eval(\"1 + 2\")<\/span> -&gt; returns 3<br \/>\n<span class=\"code-fragment\">EvalExp(1 + 2)<\/span> -&gt; returns 3<\/p>\n<p class=\"intro-text\">The most obvious difference is that Eval() expects a string and therefore the first parameter must be wrapped in quotation marks.\u00a0As EvalExp() expects an expression parameter, it doesn\u2019t require quotes.<\/p>\n<p class=\"intro-text\">Most of the time, you would need EvalExp() to hard code expressions which need to be evaluated with overridden context parameters.<\/p>\n<p class=\"intro-text\">Calling EvalExp() with only 1 parameter would be the same as not using EvalExp() at all.<\/p>\n<p class=\"intro-text\"><strong>Using EvalExp with Tag Syntax<\/strong>:<\/p>\n<p class=\"intro-text\">The following expression:<\/p>\n<pre>EvalExp({myTag}, \"sampleMethod\", \"Raw\", \"sampleInterval\", {du'01:00'})<\/pre>\n<p class=\"intro-text\">Is another way of writing:<\/p>\n<pre>{myTag, sampleMethod = \"Raw\", sampleInterval = {du'01:00'}}<\/pre>\n<p class=\"intro-text\">The <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/sampling\/\">Sampling<\/a>() function is also similar. This expression:<\/p>\n<pre>EvalExp({myTag} * {myTag2}, \"sampleMethod\", \"LastKnownValue\", \"sampleInterval\", {du'01:00'})<\/pre>\n<p class=\"intro-text\">Is the same as:<\/p>\n<pre>Sampling({myTag} * {myTag2}, \"LastKnownValue\", {du'01:00'})<\/pre>\n<p class=\"intro-text\">Which is the same as:<\/p>\n<pre>{myTag, sampleMethod = \"LastKnownValue\", sampleInterval = {du'01:00'}} * {myTag2, sampleMethod = \"LastKnownValue\", sampleInterval = {du'01:00'}}<\/pre>\n<h2>Examples<\/h2>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">EvalExp(\"{\" + entity + \":attribute}\")<\/span><br \/>\nExpected result: Returns <em>\"{entity:attribute}\"<\/em> as a string because that\u2019s the expression, and no data fetch will occur.<\/p>\n<p class=\"intro-text\"><strong>Overriding Context Parameters<\/strong><\/p>\n<p class=\"intro-text\">You can use EvalExp() to override context parameter values. For example, in the following function:<\/p>\n<pre>Integer(EvalExp(param[sampleInterval], \"sampleInterval\", {du'01:00'}))<\/pre>\n<p class=\"intro-text\">IFS OI Explorer shows a flat trend for the expression, with a constant value of 3,600 instead of using the trend's default Sample Interval.<\/p>\n<p class=\"intro-text\">You can also supply your own parameters. For example:<\/p>\n<pre>EvalExp(param[myTestParameter] * 2, \"myTestParameter\", 5)<\/pre>\n<p class=\"intro-text\">The IFS OI Explorer trend displays this as a flat line of 10.<\/p>\n<h2><span id=\"Release_History\">Release History<\/span><\/h2>\n<ul class=\"intro-text\">\n<li>EvalExp() 4.6.5\n<ul class=\"intro-text\">\n<li>Changed parameters to support MultiCollection values.<\/li>\n<\/ul>\n<\/li>\n<li>EvalExp() 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 EvalExp() to evaluate an expression, or to override the value of context parameters for the duration of the evaluation.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/evalexp\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":9604,"parent":3650,"menu_order":116,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100],"class_list":["post-9464","page","type-page","status-publish","has-post-thumbnail","hentry","category-tech-ref","tag-calculations","Version-4-0","Version-4-6-5","Product-srv"],"_links":{"self":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9464","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=9464"}],"version-history":[{"count":4,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9464\/revisions"}],"predecessor-version":[{"id":67797,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9464\/revisions\/67797"}],"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\/9604"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=9464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=9464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=9464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}