Skip to main content

Calculated Fields Pro

Ninjalytics includes a powerful field builder for defining your own fields based on formulas, other fields, and functions. The field builder can be launched by clicking the New Calculated Field in the Fields toggle, or by clicking the Edit button for a calculated field that is already added to the report. Any work done in the field builder to create or edit fields is global - fields and their definitions are available across reporting presets.

Field builder formulas consist of a combination of fields and/or static values that are combined using operators and/or functions to produce a single output value.

Fields​

Many of the same field types that you would see in the dropdown in the Fields section are also available for selection in the field builder. Selecting a field in the dropdown automatically adds it to the Formula box.

Functions​

Ninjalytics supports the following functions:

  • POST_TITLE() - Get post title: Gets the title for a post ID.
  • POST_CONTENT() - Get post content: Gets the content for a post ID.
  • POST_META() - Get post content: Gets a meta field value for a post ID (first argument) and meta key (second argument).
  • POST_URL() - Get permalink: Gets the permalink (URL) for a post ID.
  • TIMESTAMP_TO_STRING() - Timestamp to string: Gets a formatted date and time in the local time zone from a numeric UTC timestamp.
  • TIMESTAMP_TO_DATE() - Timestamp to date: Gets a formatted date in the local time zone from a numeric UTC timestamp.
  • TIMESTAMP_TO_TIME() - Timestamp to time: Gets a formatted time in the local time zone from a numeric UTC timestamp.
  • DATE_FROM_LOCAL() - Date from local: Gets a formatted date in the local time zone from a date or date and time in the local time zone.
  • TIME_FROM_LOCAL() - Time from local: Gets a formatted time in the local time zone from a date or date and time in the local time zone.
  • DATE_FROM_UTC() - Date from UTC: Gets a formatted date in the local time zone from a date or date and time in UTC.
  • TIME_FROM_UTC() - Time from UTC: Gets a formatted time in the local time zone from a date or date and time in UTC.
  • CONCAT() - Concatenate: Join strings of text together.
  • STRING_SEGMENTS() - String segments: Given a string (first argument) containing values separated by a delimiter (second argument - for example, comma or space; can also be more than one character), return only the values starting at a zero-based index (third argument), up to a maximum number of values (fourth argument). Negative indexes refer to the index from the end of the string instead of the start.
  • DECODE() - Decode: Given a string (first argument) in a specified character encoding (second argument), decode to UTF-8. The special value "html" for the second argument converts HTML entities to text.

You can click a function description to insert it into the formula box, or simply type the function name as shown above.

Operators​

Ninjalytics supports + (addition), - (subtraction), x (multiplication), and / (division), as well as parentheses to define order of operations. You can click an operator to insert it, or simply type the corresponding character into the formula box.