DDCount()

Format

DDCount(InputValues)

Returns

Counts of the input values for each timestamp.
Typically 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).

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.

Inputs

InputValues: A collection of values where each value contains the necessary metadata (see Useful to Know below) which indicates the name of the source entity (DDGet() and DDGetAttributes() can produce such return values).
Behaviour: Required
Dimensions: MultiCollection
Valid data types: Decimal, Integer

How to format data types

Useful to Know

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.

Examples

Expression: DDCount(DDGetAttributes(DDGetEntities("myHierarchy", 2, "rootEntity"), ":myAttribute"))
Description: 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.  
Result: Returns the count of all fetched values of "myAttribute" for each child entity maximum 2 levels below the "rootEntity" in "myHierarchy".

Tip: If you have access to the sample data, try running the following examples using the calculation tester

Expression: DDCount({SampleDDGet})
Returns: 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.
Result: 9

Expression: DDCount(DDGet("P2 Corporate", 5, "Western Australia", ":Oil Production", "{[Oil Producing Well]:Status} == 0", "Oil Producing Well"))
Returns: The count of any Oil Producing Wells that are Online, and in the state, Western Australia.
How it works: The function scans through the P2 Corporate hierarchy, starting at the node Western Australia, 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 Oil Producing Well.  For each of these entities, it then gets the data from the Oil Production attribute, but will only return this data if the Status 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.
Result: 9

Release History

  • DDCount() 4.6.5
    • Changed InputValues parameter dimension from Collection to MultiCollection.
  • DDCount() 4.5.0
    • Initial version

Comments are closed