Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Analytics and Notifications for PI System Explorer (PI Server 2024 R2)

Max

  • Last UpdatedJan 11, 2023
  • 2 minute read

Return the time-weighted or event-weighted maximum from a set of values.

Syntax

Max(x1, ... xn)

Max(array [, calculationBasis])

Arguments

  • x1, ... xn

    Arguments or a single array of same value type (integers and real numbers, enumeration values, time expressions, or time intervals)

  • calculationBasis

    Optional. The type of calculation to be performed enclosed in double quotes. Choose between "EventWeighted" or "TimeWeighted." If omitted, the default is event-weighted. If you select "TimeWeighted," the earliest timestamp of the value marks the start time and the latest timestamp the end of a time range

Returns

The maximum from a set of arguments. The result is of the same data type as the arguments

Exceptions

Arguments whose run-time values are digital states are ignored. If all values are digital states, Max returns an error. Returns an error if the array does not consist of same value type

Notes

  • Unit of Measure (UOM) of the arguments is carried over to the result when at least one argument has a defined UOM while others don't. The returned value lacks a UOM if arguments have different UOMs

Example

  • Max(14, 'att1', 14.5, TagVal('att2','14-Dec-16'))

    [Find the maximum from these values: 14, value of 'att1' at trigger time, 14.5, and the value for 'att2' at start of day (12:00am) on Dec 14, 2016]

  • Max('enum_att1', 'enum_att2', 'enum_att3')

    [At trigger time, find the highest value from an enumeration set and return its name]

  • Max('*', 'y', 'Saturday')

    [Find the most recent timestamp. Returns current time from the example above]

  • Max('*'-'*-1h', 't+8h'-'y+4h', '*'-'t')

    [Find the longest interval from these time periods: from 1 hour ago to now, from 4:00am yesterday to today at 8am, from 12:00am yesterday to 12:00am on 20th of this month, and from the beginning of day today (12:00am) till now]

  • Max(Variable1)

    Name

    Expression

    Value at Evaluation

    Variable1

    RecordedValues('att1', '*-10m', '*')

    [1, 3, 5, 7, 9]

    Variable 2

    Max(Variable1)

    9

    [Find the maximum of values in an array named Variable1]

  • Max(Data)

    [Return the event-weighted maximum of values from an array named Data]

  • Max(Data, "EventWeighted")

    [Return the event-weighted maximum of values from an array named Data]

  • Max(Data, "TimeWeighted")

    [Return the time-weighted maximum of values from an array named Data using the timestamps of the earliest and latest values of the array as the start time and end time respectively]

In This Topic
TitleResults for “How to create a CRG?”Also Available in