---
schema_version: "1"
id: 36c8eeb0071e9ccc9b8d2818a5566da0fce103fd6d99d5354efd3e318f49baf1
title: last
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-strings-functions-last.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-strings-functions-last
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 385d3ee9c42ff08317065ac895b4ab4f1ae8ead202d64d1f3eb7a252e17fc057
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# last

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## last(text: String, amount: Number): String

Returns characters from the end of string to a specified number of characters, for example, the last
two characters of a string.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>text</code></p></td><td><p>The string to process.</p></td></tr><tr><td><p><code>amount</code></p></td><td><p>The number of characters to return. Negative numbers and <code>0</code> return an empty string. Decimals are rounded up to the nearest whole number.</p></td></tr></tbody></table>

### Example

This example returns the last six characters from a string.

#### Source

```DataWeave
%dw 2.0
import last from dw::core::Strings
output application/json
---
"hello world!" last 6
```

#### Output

```Json
"world!"
```

## last(text: Null, amount: Any): Null

Helper function that enables `last` to work with a `null` value.

_Introduced in DataWeave version 2.4.0._
