{"id":28001,"date":"2017-06-16T14:16:54","date_gmt":"2017-06-16T06:16:54","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=28001"},"modified":"2024-01-17T10:47:59","modified_gmt":"2024-01-17T02:47:59","slug":"ddcount","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/ddcount\/","title":{"rendered":"DDCount()"},"content":{"rendered":"\n<h2>Format<\/h2>\n<p class=\"intro-text\"><strong>DDCount(InputValues)<\/strong><\/p>\n<h2>Returns<\/h2>\n<p class=\"intro-text\">Counts of the input values for each timestamp. <br \/>\nTypically this function is used on the return value of a DDGet() or DDGetAttributes() call since these functions can return multiple values for a single timestamp (by fetching the attribute of several entities).<\/p>\n<p class=\"left-bar-yellow\">It is possible to retrieve very large volumes of data through indiscriminate use of this function. Retrieving large amounts of Historian data across a slow network can affect system performance for all users of the system.<\/p>\n<h2>Inputs<\/h2>\n<p class=\"intro-text\"><strong>InputValues:<\/strong> A collection of values where each value contains the necessary metadata (see <a href=\"#Useful_to_Know\">Useful to Know<\/a> below) which indicates the name of the source entity (<a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/ddget\/\">DDGet<\/a>() and <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/ddgetattributes\/\">DDGetAttributes<\/a>() can produce such return values).<br \/>\nBehaviour: Required<br \/>\nDimensions: MultiCollection<br \/>\nValid data types: Decimal, Integer<\/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><span id=\"Useful_to_Know\">Useful to Know<\/span><\/h2>\n<p class=\"intro-text\">In the calculation engine, values returned by DD() functions have metadata assigned to them, such as entity name and start\/end times. Other DD() functions can use this metadata to assign additional information to values they receive. In this way, the metadata is used by nested DD() functions to reduce complexity but increase versatility. Which metadata is used and how it is used is specific to each function, and is described in the Input Values section above, where applicable.<\/p>\n<h2>Examples<\/h2>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">DDCount(DDGetAttributes(DDGetEntities(\"myHierarchy\", 2, \"rootEntity\"), \":myAttribute\"))<\/span><br \/>\nDescription: This expression produces a similar result to \"Count({childEntity1:myAttribute}, {childEntity2:myAttribute},... {childEntityN:myAttribute})\". However, DDCount() will dynamically search the hierarchy, meaning that if you add or remove wells from the hierarchy, that will automatically be taken into account in the calculation. \u00a0<br \/>\nResult: Returns the count of all fetched values of \"myAttribute\" for each child entity maximum 2 levels below the \"rootEntity\" in \"myHierarchy\".<\/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\">DDCount({SampleDDGet})<\/span><br \/>\nReturns: The count of all fetched values in the SampleDDGet calculation tag. This tag is actually the same as the DDGet() function in the below example.<br \/>\nResult: <span style=\"color: #0000ff;\">9<\/span><\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">DDCount(DDGet(\"P2 Corporate\", 5, \"Western Australia\", \":Oil Production\", \"{[Oil Producing Well]:Status} == 0\", \"Oil Producing Well\"))<\/span><br \/>\nReturns: The count of any Oil Producing Wells that are Online, and in the state, Western Australia. <br \/>\nHow it works: The function\u00a0scans through the <em>P2 Corporate<\/em> hierarchy, starting at the node <em>Western Australia<\/em>, and then starts searching down the hierarchy, to a limit of 5 levels deep. When searching, it looks for any entities that have the template <em>Oil Producing Well<\/em>.\u00a0 For each of these entities, it then gets the data from the <em>Oil Production<\/em>\u00a0attribute, but will only return this data if the <em>Status<\/em> attribute returns a 0 (i.e. the well is ONLINE). Once it has all of this (from the DDGet function), it then counts the number of values that were returned, to give a count of the wells that are Online that have any Oil Production data defined.<br \/>\nResult: <span style=\"color: #0000ff;\">9<\/span><\/p>\n<h2><span id=\"Release_History\">Release History<\/span><\/h2>\n<ul class=\"intro-text\">\n<li>DDCount() 4.6.5\n<ul class=\"intro-text\">\n<li>Changed InputValues parameter dimension from\u00a0<em>Collection<\/em>\u00a0to\u00a0<em>MultiCollection.<\/em><\/li>\n<\/ul>\n<\/li>\n<li>DDCount() 4.5.0\n<ul class=\"intro-text\">\n<li>Initial version<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Counts of the input values for each timestamp. <\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/ddcount\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":28047,"parent":3650,"menu_order":85,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100,282],"class_list":["post-28001","page","type-page","status-publish","has-post-thumbnail","hentry","category-tech-ref","tag-calculations","tag-data-dictionary","Version-4-5-0","Version-4-6-5","Product-srv"],"_links":{"self":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28001","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=28001"}],"version-history":[{"count":3,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28001\/revisions"}],"predecessor-version":[{"id":64702,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28001\/revisions\/64702"}],"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\/28047"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=28001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=28001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=28001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}