Source: https://vaultcrmhelp.veeva.com/doc/Content/CRM_topics/X_Pages/X_PagesStudio/Expressions.htm

## Using Expressions to Perform Data Calculations in X-Pages Studio

Content creators can use expressions to perform calculations on queried data for [data elements](AddData.htm) and [display elements](DefineLayout.htm). Different expressions are available for selection depending on the input data for a calculation.

**Who can use this feature?**

* Content Creators - Browser
* [Using Expressions to Perform Data Calculations in X-Pages Studio](#Using)
* Users do not require an additional license

### Configuring Using Expressions to Perform Data Calculations in X-Pages Studio for

[![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)Content Creators](#)

To configure this feature, ensure [Configuring X-Pages Studio](StudioConfigure.htm) is complete.

### Using Expressions to Perform Data Calculations in X-Pages Studio as

[![Closed](../../../../Skins/Default/Stylesheets/Images/transparent.gif)Content Creators](#)

The following expressions are available for any calculation:

To populate a field with a hard-coded value, users must enter the value and select it from the dropdown menu.

| Expression | Description |
| --- | --- |
| Addition | Returns the sum of two numbers or two duration values |
| Add to Date | Calculates a date from a given date plus a selected interval |
| All | Checks if all values in a list of values are true |
| Any | Checks if any value in a list of values if true |
| Ceiling (Date) | Calculates the date that is at the end of the week/month/quarter/year from a given date |
| Challenge Reasons for Account | Returns challenge reasons for any Account from the user's territory feedback |
| Join Multiple Texts | Joins a given list of strings into a single string |
| Count Unique | Returns the number of unique values in a given list of values |
| Date/Datetime Duration | Calculates the amount of time between a start date/datetime and an end date/datetime. Returns a Duration value.  If a Date field is selected for one input, the other input is restricted to Date fields. The same applies to Datetime fields. |
| Datetime to Date | Returns the date from the given datetime value |
| Day in Month | Returns the month day number from a given date |
| Division | Returns quotient of two numbers |
| Duration | Returns a Duration value. |
| Equals | Checks if two values are equal. Returns true or false. |
| Field from Singleton | Copies a value from any data element with a single record output |
| First Value from List | Returns a list of values for a selected field from an existing data element |
| Floor (Date) | Calculates the date that is at the beginning of the week/month/quarter/year from a given date |
| Format Date | Returns a date string in the given date format. Available date components include:   * y - year * Y - week-numbering year. Differs from the normal 'year' when a week is split across a year. * Q - quarter * M - month. Must be uppercase. M is not strictly numeric. Use MMM to get the three-letter abbreviated month name and MMMM to get the full month name. Month names are not translated. * w - week number * d - day. Must be lowercase. Use ddd to get ordinal numbers, for example, 1st or 23rd. * D - ordinal day * E - weekday name * e - weekday number   These date components can be used in any order with any normal separator, including slashes, dashes, spaces, periods, and commas. |
| Format Datetime | Returns a datetime string in the format of the user’s locale |
| Format Duration | Returns a string representation of a Duration value based on the user's locale, for example, "2 Days, 5 Hours.” This is rounded to the selected values.  Select the Time Periods to include in the formatted string:   * Years, Months * Months, Days * Weeks * Days * Hours * Days, Hours * Minutes * Days, Hours, Minutes * Hours, Minutes |
| Greater Than | Checks if a value is greater than a second value. Returns true or false. |
| Greater Than or Equals | Checks if a value is greater than or equal to a second value. Returns true or false. |
| Hardcoded Bool | User-defined true or false value |
| Hardcoded Date | User-defined date as a string |
| Hardcoded Duration | User-defined duration entered as an ISO 8601 string. Years (Y) and months (M) are not supported and must be converted to days (D). Decimals are supported. |
| Hardcoded Image | User-defined image |
| Hardcoded Number | User-defined number. Can be a float or an integer. |
| Hardcoded String | User-defined string |
| If | Defines a condition evaluating to true or false and the expected output for each result |
| In | Checks if a list of strings contains the given string. Returns true or false. |
| Is Null | Checks if a value is null. Returns true or false. |
| Is Not Null | Checks if a value is not null. Returns true or false. |
| Less Than | Checks if a value is less than a second value. Returns true or false. |
| Less Than or Equals | Checks if a value is less than or equal to a second value. Returns true or false. |
| List of Expressions | Returns a list of values of the same data type |
| Mean | Returns the mean of a given list of numbers or duration values (sum of input values) / (count of input values) |
| Median | Returns the median of a given list of numbers or duration values after values are sorted in ascending order |
| Max | Returns the maximum value from a given list of values |
| Min | Returns the minimum value from a given list of values |
| Month | Returns the month number from a given date |
| Multiplication | Returns the product of two numbers |
| Not | Returns the opposite true or false value of the given value |
| Not Equals | Checks if two values are note equal. Returns true or false. |
| Not In | Checks if a list of strings does not contain the given string. Returns true or false. |
| Number to Text | Converts a number value to text.  Select one:   * Locale aware number (default) - Must provide the number of decimals to display. Number is formatted according to the user's locale and the number of decimals specified. * Percent - Must provide the number of decimals to display. Number is formatted as a percent using the number of decimals specified. For example, 1 is rendered as 100%. * Currency - Must provide an expression that evaluates to the currency code to use for formatting (for example, USD). Number is formatted with the correct decimals for the specified currency. |
| Pick One | Returns a single value from a given list of values |
| Product | Returns the product of a given list of numbers |
| Round | Returns a number rounded to the given number of decimal places |
| Subtraction | Returns the difference of two numbers or two duration values |
| Subtract from Date | Calculates a date from a given date minus a selected interval |
| String to Image | Converts base64 to images |
| Sum | Returns the sum of a given list of numbers |
| Target Challenge Reasons for Account | Returns the target-level challenge reasons for any Account from the user's territory feedback |
| Year | Returns the year number from a given date |

The following expressions are only available when performing calculations on a selected list of records:

| Expression | Description |
| --- | --- |
| Get Related Data | Performs a calculation on a related list data element. Calculation types include retrieving a field value from the first matching record, counting matching records, summing a numeric field across all matching records, or joining a text field across all matching records. |
| Local Field | Returns a value from a field in a given data element |
| Related Field | Returns a list of values satisfying a given condition derived from a list of field values in the selected data element |

### Related Topics

[Adding Data to X-Pages in X-Pages Studio](AddData.htm)

[Defining X-Pages Layouts](DefineLayout.htm)
