# InfoPath functions with examples

A list of commonly used functions in InfoPath with examples of how those InfoPath functions can be used in formulas.

Functions in InfoPath can be used by themselves or embedded in other functions as an argument that uses the result of the embedded function to form formulas.

Below you will find a list of commonly used functions in InfoPath with a short description of what they do, and references to articles that use a particular function.

## addDays(date, days)

Add days to a date or date and time.

## avg(field)

Calculates the average of all of the numerical values in a field or group.

- InfoPath avg function in repeating table
- Using the AVG function in InfoPath
- Using InfoPath Math functions with repeating fields as input

## concat(text1, text2, ...)

Combines two or more fields or text strings into one text string.

- InfoPath 2010 functions within functions in a formula
- Dynamically append text to a label in InfoPath 2010
- Format text with proper case in InfoPath
- People picker data merging in InfoPath 2013
- Automatically change the first letter of a word/sentence to upper case
- Auto-formatting a time field in InfoPath when it loses the focus

## contains(within_text, find_text)

Returns true if the first field or text string contains the second. Otherwise it returns false.

## count(field)

Counts the number of instances of a field or group.

- Multi-select list box to show/hide columns in horizontal repeating table
- Count persons selected in a people picker in a repeating table
- InfoPath 2010 previous next navigation on a SharePoint list
- InfoPath repeating table validation check for duplicate records
- Counting the amount of documents submitted today to a SharePoint library
- Create an absence report form using rules
- Display a message box if an item does not exist in the list of entries for a combo box

## eval(field, expression)

Returns the values of a field or group. The second argument defines the expression to calculate for the field or group. Usually, the eval function is nested within a function that operates on a field or group, such as sum or avg.

- Using InfoPath Math functions with repeating fields as input
- Multi-select list box to show/hide columns in horizontal repeating table
- People picker data merging in InfoPath 2013
- InfoPath eval and sum functions to get the total length of strings in a repeating table

## floor(number)

Rounds a number down to the nearest integer.

- Forcing users to select a particular day of the week from a date picker in InfoPath using rules and formulas
- Create a day of the week InfoPath form using rules and formulas
- Calculate the difference between two date picker controls in InfoPath using rules and formulas - no code!

## max(field)

Returns the largest number in a field or group.

- Select the latest date from a repeating table in InfoPath
- Auto-numbering InfoPath forms when they are submitted to a SharePoint form library
- How do I avoid getting NaN when using the max() function?
- Using InfoPath Math functions with repeating fields as input

## min(field)

Returns the smallest number in a field or group.

- Selecting the minimum date in an InfoPath repeating table using formulas (no code)
- Using InfoPath Math functions with repeating fields as input

## not(boolean_value)

Removes whitespace from a text string.

## now()

Returns the current system date and time.

- InfoPath substring-after and substring-before functions
- InfoPath 2010 date and time picker control basics
- Default to Monday in the current week in InfoPath 2010

## number(value)

Converts a value to a number.

- Extracting day, month, and year numbers from dates in InfoPath
- Forcing users to select a particular day of the week from a date picker in InfoPath using rules and formulas
- Create a day of the week InfoPath form using rules and formulas
- Calculate the difference between two date picker controls in InfoPath using rules and formulas - no code!
- How do I subtract lunch hours from time calculations?
- Calculating time differences in InfoPath without custom code
- InfoPath 2010 previous next navigation on a SharePoint list
- Create an absence report form using rules

## string-length(text)

Returns the number of characters in a text string.

- InfoPath 2013 LEFT and RIGHT functions
- Format text with proper case in InfoPath
- How to set the maximum field length in InfoPath
- Automatically change the first letter of a word/sentence to upper case
- InfoPath eval and sum functions to get the total length of strings in a repeating table

## substring(text, start_position, char_count)

Returns a specific part of a text string. The second argument specifies the starting position and the third argument specifies how many characters to include.

- InfoPath 2013 LEFT and RIGHT functions
- Extracting day, month, and year numbers from dates in InfoPath
- How do I subtract lunch hours from time calculations?
- InfoPath 2010 functions within functions in a formula
- Calculating time differences in InfoPath without custom code
- Auto-formatting a time field in InfoPath when it loses the focus

## substring-after(text, find_text)

Returns the text in the first text string that follows the first occurrence of the second text string.

## substring-before(text, find_text)

Returns the text in the first text string that precedes the first occurrence of the second text string.

## sum(field)

Returns the sum of all fields in a field or group. Each field is first converted to a number value.

- InfoPath sum function to calculate repeating table sum
- InfoPath repeating table sum
- InfoPath 2010 running total sum in repeating table
- Using InfoPath Math functions with repeating fields as input
- Calculating time differences in InfoPath without custom code
- InfoPath eval and sum functions to get the total length of strings in a repeating table

## today()

Returns the current system date. For SharePoint list date fields, use the now() function.

- Counting the amount of documents submitted today to a SharePoint library
- Default to Monday in the current week in InfoPath 2010

## translate(text, find_chars, replace_chars)

Returns the first text string with each character in the second text string replaced by the character at the corresponding position in the third text string.

- InfoPath 2010 functions within functions in a formula
- Format text with proper case in InfoPath
- Automatically change the first letter of a word/sentence to upper case

## userName()

Returns the user name of the person filling out the form (Microsoft InfoPath 2007 and later).