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 2018)

Median

  • Last UpdatedJan 11, 2023
  • 2 minute read

Return the time-weighted or event-weighted median (middle value) of one or more values.

Syntax

Median(x1 [, ... xn])

Median(array)

Arguments

  • x1 [, ... xn]

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

Returns

The median value of the input argument(s). If there are even number of arguments, the average of the two middle values is returned. Returns an error if the array does not consist of same value type

Exceptions

Arguments whose run-time values are digital states are ignored. The function must have one or more arguments that evaluate to non-digital states; otherwise, Median returns an error value. Also returns an error if the array does not consist of same value type

Notes

Arguments must be of same value type. The data type of the first argument sets the tone for the rest

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

Examples

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

    [Find the median of these values: 14, the current value of att1, 14.5, and the value for att2 at midnight on Dec 14, 2016]

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

    [Find the median of these timestamps: now, 12:00am yesterday, and 12:00am last Saturday]

  • Median('*'-'*-1h', 't+4h'-'y+8h', 'y+2h'-'20')

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

  • Median(Variable1)

    Name

    Expression

    Value at Evaluation

    Variable1

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

    [1, 3, 5, 7, 9]

    Variable 2

    Median(Variable1)

    5

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

  • Median(Data)

    [Return the event-weighted median of values for an array named Data]

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