Formula - Count

The count( ) Formula function is pretty straight-forward and self-explanatory function. it is used to return the number of the unique extracted values from Content.

Quick example

Let's get you started with the following simple demonstration example valid for this Formula plugin. For other and more advanced examples please scroll down on this page to the Examples section.

Input Expression Result

  Nodinite


 count(body)

1
Text Data count expression Unique values

Syntax

count(Content)

On the Message Body :

On the Message Context :

Features

count( ) function is applicable any where as long as there is valid Content parameter , it doesn't matter if the content parameter a plain text or any valid Formula Plugin function. Please notice that is the retrieved number representing the unique count of the extracted values, more on this later below.

  • Return the count of extracted values from the Content.
  • It returns the count of the unique values from Content
  • Can be applied on any valid Content that return data; Like jsonpath, xpath functions or even a plain text, review Formula user guide for complete list of functions.

This plugin loads the entire message into RAM, so make sure to apply this function on smaller messages only

How to use

In order to use the count function the Content parameter should contain data (otherwise it will fail and you will end up with nothing). But first and foremost we have to configure the Formula plugin:

  • Select Formula as expression type plugin.
  • Write down the expression to use in the 'Expression' text area.
  • Input a proper Content as parameter to the function.

Syntax

Use the count function with any of the following parameters:

  • From Message Body: count(body)

  • From Message Context: count(context('MessageContextKey'))

  • Result from previous Formula operation count(SomeOtherNestedFormulaFunction(Content))

Examples

Below you will find different common examples for how to use the count function.

Body as Content

"Nodinite" is the message body text, by using the provided expression the result will be 1.

e.g. count(body)

simpleBody

Message Body


 Nodinite

Expression


count(body)


Context as Content

"Nodinite" is the value for the corresponding key "id", by using the provided expression the result will be 1.

e.g. count(context('id'))

messageContext

Message Context Value


  Nodinite

Expression


 count(context('id'))


Formula Function as Content

The message body is json structure, , by using the provided expression the result will be 3. e.g. count(jsonpath('a[*].b', body))

jsonpath

Message Body


{a:[{b:'This'},{b:'is'},{b:'Formula Plugin'}]}

Expression


count(jsonpath('a[*].b', body))


Next Step

How to Add or manage Search Fields
How to Add or manage Log Views

Expression Type Plugins are used in Search Fields
What are Search Fields?
What are Search Field Expressions?
What are Message Types?
What are Log Views?