> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# Greatest

> Returns the greatest value from two or more values with matching data types.

Returns the greatest value from two or more values with matching data types.

## Syntax

```
Greatest(input1, [input2], ...)
```

**input 1** (required) The data or column of data to be evaluated. Input can be numbers, dates, or strings.

**input 2+** (optional) Additional inputs to compare. All additional inputs must match the type of the first input.

## Notes

* To compare two values of different data types, convert one of the values to match the data type of the other using the appropriate type conversion function. For example, you can convert a string to a number using the [Number](/docs/number) function, or to a date using the [Date](/docs/date) function.

## Example

```
Greatest(1, 2)
```

* Returns `2`.

```
Greatest([Date], Date("2025-12-20"))
```

* In a calculated column, converts the text "2025-12-20" to a date, then compares it to the date in the *Date* column and returns the later of the two.

![A table with three columns, Order Number, Date, and Greatest. The Greatest column shows the later of the two dates between "2025-12-20" and the date in the Date column for each row](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/663756866b4dbb74bfb0d85803c80418e28f7009064044de7f723f3b2a6a0669/assets/docs-images/269ad352ef9c021dc8c05e28d80c95115a95e4ef75b4af0872fbac8078f11c3a-greatest_column_example.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260726%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260726T044241Z&X-Amz-Expires=604800&X-Amz-Signature=8596f704240c412c72382f9130c80e7dbe412798a13a1e89802571c07394ce4f&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

```
Greatest([Profit 2022], [Profit 2023], [Profit 2024])
```

* In a table summary, returns the profit for the year with the highest profit.

![A table with four table summaries, one for each of the years 2022, 2023, and 2024, and one for the most profitable year. The most profitable year is 2024](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/2ecee846b876d2c0dc6bfdd398e1161be89894966e195292dc3f053cd62b8eaa/assets/docs-images/f482262b79c830e1d6b97ce3629de0367bf32ca93a43f519f298d92ee4288838-greatest_example_table_summary.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260726%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260726T044241Z&X-Amz-Expires=604800&X-Amz-Signature=1a2a3ac53d7a8f60687f927af5cd49786dc5badcd5b483068b0ab315db28ec60&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

## Related resources

* [Max](/docs/max)
* [Least](/docs/least)
* [LeastNonNull](/docs/leastnonnull)
* [GreatestNonNull](/docs/greatestnonnull)