LogoLogo
API Documentation
Current Version
Current Version
  • DecisionRules Documentation
  • DecisionRules Academy
  • API
    • API Introduction
    • API Keys
      • Solver API Keys
      • Management API keys
      • BI API keys
    • Rule Solver API
    • Management API
      • Rule Migration Strategies
      • Deprecated Endpoints
    • Console Logs API
    • Business Intelligence API
      • Deprecated Endpoints
    • Datacenters & Locations
      • Global Cloud
      • Regional Cloud
    • Apache Kafka Solver API
    • Endpoint Settings
    • Archive
      • Rule Flow Solver API (DEPRECATED)
  • AI Assistant
    • About Assistant
    • Assistant Setup
      • Gemini Assistant
  • RULES
    • Rules Introduction
    • Rule List
    • Rule Mode
    • Common Rule Features
      • Input & Output Model
        • Simple Editor
        • JSON Editor
      • Test Bench
      • Rule Alias
      • Rule State
      • Versioning
      • Rule Variables
      • Execution Strategy
      • Rule Dependencies
      • Rule Export & Import
        • Rule Export
        • Rule Import
        • Managing Decision Table in Excel/Google Sheets
        • Deprecated Formats: XLSX v.1 and CSV
      • Tags
      • Rule Comparison
        • Decision Table Comparison
        • Decision Tree Comparison
        • Scripting Rule Comparison
      • Rule Lock
      • Teamwork Indicator
      • Event Timeline
    • Data Types & Functions
      • Supported Data Types
      • Operators and Functions
        • Basic operators
        • Date operators
        • Functions
          • Logical Functions
          • Math Functions
          • Date and Time Functions
          • Text Functions
          • Data Functions
          • Array Functions
          • Integration functions
          • Functions and JSON
    • Decision Table
      • Table Designer
        • Table Operations
          • Filter Values
          • Valid Values
          • Sorting
      • Binding to Model
    • Decision Tree
      • Tree Designer
    • Workflow
      • Workflow Designer
      • Workflow Nodes Overview
      • Workflow Limits
    • Scripting Rule
      • Custom functions in Scripting Rules
      • Calling external API within ScriptingRules
      • Use Rule Variables in Scripting Rules
      • Call Embedded Rules in Scripting Rules
      • Tips
    • Rule Flow
      • Rule Flow Designer
      • Rule Flow Mapping
      • Rule States in Rule Flow
      • Warnings & Errors
      • Rule Flow Limits
  • SPACE
    • Space Introduction
    • Space Info
    • Dashboard
    • Access
    • API Keys
    • Audit Logs
  • Organization
    • Organization Introduction
    • Organization List
    • Members
    • Teams
    • Spaces
    • Space Roles
    • Policies
    • Statistics
    • Settings
  • Profile
    • Profile Introduction
    • General
    • Dashboard
    • Plans
    • Add-ons
    • Limits
      • Plan Limits Explained
    • Subscriptions
    • Invoices
  • Access
    • Sign Up & Login
    • Invitations & Permissions
    • Single Sign-On (SSO)
  • Business Intelligence
    • Audit Logs
    • Power BI Connectivity
      • Create a Power BI Report
      • Connect Power BI to Business Intelligence API
      • Connecting from Power BI (deprecated)
      • Connect DecisionRules to Power BI Using Our Custom Connector
  • OTHER DEPLOYMENT OPTIONS
    • Regional Cloud
      • Region Specific API URLs
    • Docker & On-Premise
      • Environment Variables
      • Redis Connection Modes
      • DecisionRules Application
        • Minimal Requirements
        • DecisionRules Server
        • DecisionRules Client
        • DecisionRules Business Intelligence
        • Networking Between Docker Containers
      • Setup Single Sign-On (SSO)
        • Set up Microsoft Entra ID SSO
        • Set up Google SSO
      • Docker Showcase App
        • Showcase
        • Showcase + Business Intelligence
      • AWS Setup
        • AWS ECS/Fargate
        • Cache - Amazon ElastiCache
      • Microsoft Azure Setup
        • Database - Azure CosmosDB
        • Cache - Azure Cache for Redis
        • Azure Container Apps
      • Azure Red Hat OpenShift
      • Google Kubernetes Engine (GKE)
      • Kubernetes Setup
        • Kubernetes Setup with Business Intelligence
      • Logging options
      • CD/CI Pipelines
        • Azure DevOps CICD Pipelines
        • Using Migration script (old way)
      • Offline License
      • White Labeling
  • SDK and Integrations
    • Languages / Frameworks
      • SQL Server
      • Oracle PL/SQL
      • PostgreSQL
      • JavaScript
      • Java Spring Example
      • PHP Library
      • Python Library
      • .NET Library
      • Google Tag Manager
    • Excel Add-in
  • Terms & Conditions
    • Terms and Conditions
    • Privacy Policy
    • Service Level Agreement
      • Community Support
      • Standard Cloud (SaaS)
      • Silver SLA
      • Gold SLA
      • Custom SLA
    • Sub-Processor List
  • Product Updates
    • Release Notes
      • Public Cloud
      • On-Premise / Private Cloud
    • Major Updates
      • Changes in Version 1.19.0 (10/2024)
      • Changes in Version 1.20.0 (4/2025)
    • Roadmap
Powered by GitBook
On this page
  • List of array functions
  • Examples
  • Specifications
  • Pick values from and array of nested objects (ARRAY_PICK)
  • Map array to another array (ARRAY_MAP)
  • Reduce array with custom function (ARRAY_REDUCE)
  • Filter array with custom function (ARRAY_FILTER)
  • Check if array includes an element (ARRAY_INCLUDES)
  • Flatten an array (ARRAY_FLATTEN)
  • Summation over an array (ARRAY_SUM) (deprecated)
  • Concatenation over an array (ARRAY_CONCAT) (deprecated)
  • Concatenation over an array with a separator (ARRAY_CONCAT_WS) (deprecated)
  • Logical conjunction over an array (ARRAY_AND) (deprecated)
  • Logical disjunction over an array (ARRAY_OR) (deprecated)

Was this helpful?

  1. RULES
  2. Data Types & Functions
  3. Operators and Functions
  4. Functions

Array Functions

Last updated 7 months ago

Was this helpful?

List of array functions

Deprecated functions

  • ARRAY_AND

  • ARRAY_OR

  • ARRAY_SUM

  • ARRAY_CONCAT

  • ARRAY_CONCAT_WS

Examples

The below provided decision table contains examples of all the supported array functions (excluding the deprecated ones). Import the decision table to your space to see them working.

Specifications

Below you will find the specifications of all the array functions.

Pick values from and array of nested objects (ARRAY_PICK)

Given an array of objects and a JSON path to certain (string) values nested inside these objects, the ARRAY_PICK function picks these values and returns them in an array.

  • Requires 2 arguments: the array and the path.

  • The first argument must be a variable or another function returning an array.

  • The second argument must be a string specifying JSON path to the desired string values.

The JSON path is simply the sequence of keys separated by dots. You can access elements in an array by writing the index of the element in square brackets behind the key pointing to that array. Note that elements in an array are indexed from 0! For example, animals[0] points to the first element of the animals array.

INPUT1 = [
    {"order":{"code":"A"}},
    {"order":{"code":"B"}},
    {"order":{"code":"C"}}
  ]
 
INPUT2 = [
    {"order": [
        {"code":"A2", "price":22},
        {"code":"B3", "price":11}
               ]
    },
    {"order": [
        {"code":"A5", "price":55},
        {"code":"B8", "price":88}
        ]
    }
  ]
 
[function] --> [output]

ARRAY_PICK({INPUT1}, "order.code")        --> ["A", "B", "C"]
ARRAY_PICK({INPUT2}, "order[0].code")     --> ["A2", "A5"]
ARRAY_PICK({INPUT2}, "order[1].price")    --> [11, 88]

Map array to another array (ARRAY_MAP)

Thanks to ARRAY_MAP, you can transform an array of values or objects to another array. Given an array and a representation of a custom function of a single argument, the ARRAY_MAP function applies the custom function to every element of the given array and returns the resulting array.

  • Requires 3 arguments: the array, name of a custom argument and a custom function.

  • The first argument must be a variable or another function returning an array.

  • The second argument must be a string specifying the name of a custom argument.

  • The third argument must be a function of the custom argument.

INPUT = [1,2,3]
 
[function] --> [output]

ARRAY_MAP({INPUT}, "x", SUM({x},1))   --> [2,3,4]
ARRAY_MAP({INPUT}, "z", TIMES(3,{z})) --> [3,6,9]
ARRAY_MAP({INPUT}, "element", CONCAT_WS(" ", "number", {element}))
                                      --> ["number 1","number 2","number 3"]

Reduce array with custom function (ARRAY_REDUCE)

Thanks to ARRAY_REDUCE, you can reduce an array of values to a single value. Given an array and a representation of a custom function of 2 arguments, the ARRAY_REDUCE function applies the custom function successively (to the first couple of elements, to the result and the third element, to the result and the fourth element, etc.) and returns the resulting value.

  • Requires 4 arguments: the array, 2 names of custom arguments and a custom function.

  • The first argument must be a variable or another function returning an array.

  • The second argument must be a string specifying the name of the first custom argument.

  • The third argument must be a string specifying the name of the second custom argument.

  • The last, fourth argument must be a function of the 2 custom arguments.

INPUT1 = [1,2,3,4]
INPUT2 = [true,true,false]
 
[function] --> [output]

ARRAY_REDUCE({INPUT1}, "x", "y", SUM({x},{y}))     --> 10
ARRAY_REDUCE({INPUT1}, "a", "b", TIMES({a},{b}))   --> 24
ARRAY_REDUCE({INPUT1}, "word1", "word2", CONCAT_WS("_",{word1},{word2}))
                                                   --> "1_2_3_4"
ARRAY_REDUCE({INPUT2}, "a", "b", AND({a},{b}))     --> false
ARRAY_REDUCE({INPUT2}, "a", "b", OR({a},{b}))      --> true

Filter array with custom function (ARRAY_FILTER)

The ARRAY_FILTER function filters an array based on a custom function and returns another array with a subset of the elements of the original array.

  • Requires 3 arguments: the array, a name of a custom argument and a custom function.

  • The first argument must be a variable or another function returning an array.

  • The second argument must be a string specifying the name of the custom argument.

  • The third argument must be a function of the custom argument returning a boolean value.

INPUT1 = [1,8,12,4]

INPUT2 = [
    {"code":"A","quantity":"1"}
    {"code":"B","quantity":"4"}
    {"code":"A","quantity":"3"}
    {"code":"B","quantity":"5"}
  ]
 
[function] --> [output]

ARRAY_FILTER({INPUT1}, "x", LT({x},5))    --> [1,4]
ARRAY_FILTER({INPUT2}, "a", EQ(PICK({a},"code"),"B"))
--> [
      {"code":"B","quantity":"4"}
      {"code":"B","quantity":"5"}
    ]

Check if array includes an element (ARRAY_INCLUDES)

Checks whether an array includes a given element.

  • Requires 2 arguments: the array and the element to search for.

  • The first argument must be a variable or another function returning an array.

  • The second argument can have any value.

INPUT = [
    {"code":"A","quantity":"1"}
    {"code":"B","quantity":"4"}
    {"code":"A","quantity":"3"}
    {"code":"B","quantity":"5"}
  ]
 
[function] --> [output]

ARRAY_INCLUDES([1,5,10],6)                              --> false
ARRAY_INCLUDES([1,5,10],5)                              --> true
ARRAY_INCLUDES({INPUT},{"code":"A","quantity":"3"})     --> true

Flatten an array (ARRAY_FLATTEN)

Flatten an array of arrays up to the specified depth.

  • Takes 1 or 2 arguments

  • The first argument is a string to flatten.

  • The second optional argument specifies the depth to which to flatten the array (by default the argument is flattened into one dimension).

  • If the first provided argument isn't an array the function returns null

  • The second optional argument has to be a positive Integer, else the function returns null

INPUT = [1, 2, [3,4], [[5]]]

[function] --> [output]

ARRAY_FLATTEN({INPUT})   --> [1,2,3,4,5]
ARRAY_FLATTEN({INPUT}, 1) --> [1,2,3,4,[5]]
ARRAY_FLATTEN({INPUT}, "string") --> null
ARRAY_FLATTEN({INPUT}, -1) --> null

Summation over an array (ARRAY_SUM) (deprecated)

This function is deprecated. Use SUM instead (if you need to get nested values, you can use SUM in combination with ARRAY_PICK).

Given an array of numeric values (or alternatively objects), ARRAY_SUM returns their sum.

  • Requires 1 argument, the array.

  • The argument must be a variable or another function returning an array.

  • There can be a second optional argument of type string specifying JSON path to numeric values nested within the elements of the array (in case they are objects).

  • Can be a part of an embedded function.

The json path is simply the sequence of keys separated by dots. You can access elements in an array by writing the index of the element in square brackets behind the key pointing to that array. Note that elements in an array are indexed from 0! For example, animals[0] points to the first element of the animals array.

INPUT1 = [1,2,3]

INPUT2 = [
    {"order":{"price":20}},
    {"order":{"price":30}},
    {"order":{"price":40}}
  ]
 
INPUT3 = [
    {"order": [
        {"code":"A2", "price":22},
        {"code":"B3", "price":11}
               ]
    },
    {"order": [
        {"code":"A5", "price":55},
        {"code":"B8", "price":88}
        ]
    }
  ]
 
[function] --> [output]

ARRAY_SUM({INPUT1})                       --> 6
ARRAY_SUM({INPUT2}, "order.price")        --> 90
ARRAY_SUM({INPUT3}, "order[0].price")     --> 77
ARRAY_SUM({INPUT3}, "order[1].price")     --> 99

Concatenation over an array (ARRAY_CONCAT) (deprecated)

This function is deprecated. Use CONCAT instead (if you need to get nested values, you can use CONCAT in combination with ARRAY_PICK).

Given an array of string values (or alternatively objects), the ARRAY_CONCAT function concatenates these values and returns the concatenated string.

  • Requires 1 argument, the array.

  • The argument must be a variable or another function returning an array.

  • There can be a second optional argument of type string specifying JSON path to numeric values nested within the elements of the array (in case they are objects).

  • Can be a part of an embedded function.

The json path is simply the sequence of keys separated by dots. You can access elements in an array by writing the index of the element in square brackets behind the key pointing to that array. Note that elements in an array are indexed from 0! For example, animals[0] points to the first element of the animals array.

INPUT1 = ["a","b","c"]

INPUT2 = [
    {"order":{"code":"A"}},
    {"order":{"code":"B"}},
    {"order":{"code":"C"}}
  ]
 
INPUT3 = [
    {"order": [
        {"code":"A2", "price":22},
        {"code":"B3", "price":11}
               ]
    },
    {"order": [
        {"code":"A5", "price":55},
        {"code":"B8", "price":88}
        ]
    }
  ]
 
[function] --> [output]

ARRAY_CONCAT({INPUT1})                      --> "abc"
ARRAY_CONCAT({INPUT3}, "order[0].code")     --> "A2A5"
ARRAY_CONCAT({INPUT3}, "order[1].code")     --> "B3B8"

Concatenation over an array with a separator (ARRAY_CONCAT_WS) (deprecated)

This function is deprecated. Use CONCAT_WS instead (if you need to get nested values, you can use CONCAT_WS in combination with ARRAY_PICK).

Given a separator and an array of string values (or alternatively objects), the ARRAY_CONCAT_WS function concatenates these values with the given separator and returns the concatenated string.

  • Requires 2 arguments: the separator and the array.

  • The first argument must be a string separator.

  • The second argument must be a variable or another function returning an array.

  • There can be a third optional argument of type string specifying JSON path to numeric values nested within the elements of the array (in case they are objects).

  • String arguments should be enclosed in "".

The json path is simply the sequence of keys separated by dots. You can access elements in an array by writing the index of the element in square brackets behind the key pointing to that array. Note that elements in an array are indexed from 0! For example, animals[0] points to the first element of the animals array.

INPUT1 = ["a","b","c"]

INPUT2 = [
    {"order":{"code":"A"}},
    {"order":{"code":"B"}},
    {"order":{"code":"C"}}
  ]
 
INPUT3 = [
    {"order": [
        {"code":"A2", "price":22},
        {"code":"B3", "price":11}
               ]
    },
    {"order": [
        {"code":"A5", "price":55},
        {"code":"B8", "price":88}
        ]
    }
  ]
 
[function] --> [output]

ARRAY_CONCAT_WS("_", {INPUT1})                      --> "a_b_c"
ARRAY_CONCAT_WS("_", {INPUT2}, "order.code")        --> "A_B_C"
ARRAY_CONCAT_WS("_", {INPUT3}, "order[0].code")     --> "A2_A5"
ARRAY_CONCAT_WS(" ", {INPUT3}, "order[1].code")     --> "B3 B8"

Logical conjunction over an array (ARRAY_AND) (deprecated)

This function is deprecated. Use AND instead (if you need to get nested values, you can use AND in combination with ARRAY_PICK).

Given an array of boolean values (or alternatively objects), ARRAY_AND returns their logical conjunction.

  • Requires 1 argument, the array.

  • The argument must be a variable or another function returning an array.

  • There can be a second optional argument of type string specifying JSON path to numeric values nested within the elements of the array (in case they are objects).

  • Can be a part of an embedded function.

The json path is simply the sequence of keys separated by dots. You can access elements in an array by writing the index of the element in square brackets behind the key pointing to that array. Note that elements in an array are indexed from 0! For example, animals[0] points to the first element of the animals array.

INPUT1 = [true,true,false]

INPUT2 = [
    {"order":{"sent":true}},
    {"order":{"sent":true}},
    {"order":{"sent":true}}
  ]
 
[function] --> [output]

ARRAY_AND({INPUT1})                   --> false
ARRAY_AND({INPUT2}, "order.sent")     --> true

Logical disjunction over an array (ARRAY_OR) (deprecated)

This function is deprecated. Use OR instead (if you need to get nested values, you can use OR in combination with ARRAY_PICK).

Given an array of boolean values (or alternatively objects), ARRAY_OR returns their logical disjunction.

  • Requires 1 argument, the array.

  • The argument must be a variable or another function returning an array.

  • There can be a second optional argument of type string specifying JSON path to numeric values nested within the elements of the array (in case they are objects).

  • Can be a part of an embedded function.

The json path is simply the sequence of keys separated by dots. You can access elements in an array by writing the index of the element in square brackets behind the key pointing to that array. Note that elements in an array are indexed from 0! For example, animals[0] points to the first element of the animals array.

INPUT1 = [true,false,false]

INPUT2 = [
    {"order":{"sent":false}},
    {"order":{"sent":false}},
    {"order":{"sent":false}}
  ]
 
[function] --> [output]

ARRAY_OR({INPUT1})                   --> true
ARRAY_OR({INPUT2}, "order.sent")     --> false

ARRAY_PICK
ARRAY_MAP
ARRAY_REDUCE
ARRAY_FILTER
ARRAY_INCLUDES
ARRAY_FLATTEN
49KB
Array_Functions_Example_v1.json