You are viewing the documentation for Blueriq 17. Documentation for other versions is available in our documentation directory.

Learn more about the statistical functions AVG (average), COUNT, MAX, MIN. 

Overview

FunctionDescription
AVG (for average)Determines the average (arithmetic mean) of a list or collection.
COUNTRetrieves the number of instances for the specified entities or attributes. 
MAXDetermines the maximum value of a list or collection.
MINDetermines the minimum value of a list or collection.

Functions

AVG (for average)


Determines the average (arithmetic mean) of a list or collection.


The AVG function has two syntax forms: the collection form and the list form. You can use the collection form to determine the average value of all occurrences of an attribute. The list form is used to determine the average value of a set of different attributes.


1. Collection form syntax

AVG ( attribute )



Input
  • attribute - An attribute of any type of integer, number or date of which multiple instances can occur at runtime.


2. List form syntax

AVG ( [ value1 , value2 , ... ] )



Inputs
  • [ value1 , value2 , … ] - A list of attributes, expressions or fixed values of any type of integer, number or date. Use the square brackets to indicate that the arguments form a list of values.


Return types

  • number
  • currency
  • percentage
  • date

The function returns UNKNOWN if one or more values are UNKNOWN.


Examples

Suppose the following domain model.


Entity.attributeValueMultivalued relationEntity.attributeValues

Residence.appraisalValue

Residence.askingPrice

Residence.mortgage

€ 140000

€ 150000

€ 142000

hasBiddingsBidding.amount

€ 132000

€ 139000

€ 137500

GoalExpressionResultType
To determine the average amount within the appraisal value, the asking price and the mortgageAVG ( [ Residence.appraisalValue , Residence.askingPrice , Residence.mortgage ] )€ 144000Currency
To determine the average bidding on the current residenceAVG ( Residence.hasBiddings.amount )€ 136166.67Currency



Back to Top


COUNT


Retrieves the number of instances for the specified entities or attributes. Please note the similar function SIZE.


Syntax

COUNT ( collection )


Input

  • collection - A collection of attribute or entity instances.


Return type

  • integer


Examples

Suppose the following data model.


InstancePerson.name
1“John”
2“Dave”
3“Jane”
4“Lisa”


InstanceHouse.rooms
singleton“living room”,  “bathroom”,  “bedroom”

ExpressionResultType
COUNT ( ALL Person )4Integer
COUNT ( House.rooms )3Integer
COUNT ( ALL Person + ALL House )5Integer
COUNT ( COLLECT Person FROM ALL Person WHERE ( Person.name = “Lisa” ) )1Integer
COUNT ( ? (= UNKNOWN) )UNKNOWNInteger

SIZE and COUNT are similar except for ?:

SIZE( ? ) results in 0, while COUNT( ? ) results in ?


MAX


Determines the maximum value of a list or collection.


The MAX function has two syntax forms: the collection form and the list form. You can use the collection form to determine the maximum value of all occurrences of an attribute. The list form is used to determine the maximum value of a set of different attributes.


1. Collection form syntax

MAX ( attribute )


Input

  • attribute - An attribute of any type of integer, number, date or string of which multiple instances can occur at runtime.


2. List form syntax

MAX ( [ value1 , value2 , ... ] )


Inputs

  • [ value1 , value2 , … ] - A list of attributes, expressions or fixed values of any type of integer, number, date or string. Use the square brackets to indicate that the arguments form a list of values.


Examples

Suppose the following domain model.



Entity.attributeValueMultivalued relationEntity.attributeValues

Residence.appraisalValue

Residence.askingPrice

Residence.mortgage

€ 140000

€ 150000

€ 142000

hasBiddingsBidding.amount

€ 132000

€ 139000

€ 137500

GoalExpressionResultType
To determine the largest amount within the appraisal value, the asking price and the mortgageMAX ( [ Residence.appraisalValue , Residence.askingPrice , Residence.mortgage ] )€ 150000Currency
To determine the highest bidding on the current residenceMAX ( Residence.hasBiddings.amount )€ 139000Currency


Example with strings

ExpressionResult
MAX( ["after", "action"] )"after"


Back to Top


MIN


Determines the minimum value of a list or collection.


The MIN function has two syntax forms: the collection form and the list form. You can use the collection form to determine the minimum value of all occurrences of an attribute. The list form is used to determine the minimum value of a set of different attributes.


1. Collection form syntax

MIN ( attribute )



Input
  • attribute - An attribute of any type of integer, number, date or string of which multiple instances can occur at runtime.


2. List form syntax

MIN ( [ value1 , value2 , ... ] )



Input
  • [ value1 , value2 , … ] - A list of attributes, expressions or fixed values of any type of integer, number, date or string. Use the square brackets to indicate that the arguments form a list of values.


Examples

Suppose the following domain model.


Entity.attributeValueMultivalued relationEntity.attributeValues

Residence.appraisalValue

Residence.askingPrice

Residence.mortgage

€ 140000

€ 150000

€ 142000

hasBiddingsBidding.amount

€ 132000

€ 139000

€ 137500



GoalExpressionResultType
To determine the smallest amount within the appraisal value, the asking price and the mortgageMIN ( [ Residence.appraisalValue , Residence.askingPrice , Residence.mortgage ] )€ 140000Currency
To determine the lowest bidding on the current residenceMIN ( Residence.hasBiddings.amount )€ 132000Currency



Example with strings

ExpressionResult
MIN( ["after", "action"] )"action"


Back to Top