# MinString - script function

MinString() finds string values in the expression and returns the first text value sorted over a number of records, as defined by a group by clause.

Syntax:

MinString (MinString ( expr expr ))

Return data type: dual

Arguments:

MinString arguments

| Argument | Description |
| --- | --- |
| expr | The expression or field containing the data to be measured. |

Limitations:

If no text value is found, NULL is returned.

Examples and results:

Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in your document to see the result.

Examples and results

| Example | Result field | Result value |
| --- | --- | --- |
| `TeamData:<br>`<br>`LOAD * inline [`<br>`SalesGroup\|Team\|Date\|Amount<br>`<br>`East\|Gamma\|01/05/2013\|20000<br>`<br>`East\|Gamma\|02/05/2013\|20000<br>`<br>`West\|Zeta\|01/06/2013\|19000<br>`<br>`East\|Alpha\|01/07/2013\|25000<br>`<br>`East\|Delta\|01/08/2013\|14000<br>`<br>`West\|Epsilon\|01/09/2013\|17000<br>`<br>`West\|Eta\|01/10/2013\|14000<br>`<br>`East\|Beta\|01/11/2013\|20000<br>`<br>`West\|Theta\|01/12/2013\|23000<br>`<br>`] (delimiter is '\|');`<br>` `<br>`Concat1:`<br>`LOAD SalesGroup,MinString(Team) as MinString1  Resident TeamData Group By SalesGroup;` | SalesGroup<br><br>East<br><br>West | MinString1<br><br>Alpha<br><br>Epsilon |
| Given that the TeamData table is loaded as in the previous example, and your load script has the SET statement:<br>`SET DateFormat='DD/MM/YYYY';`':<br><br>`LOAD SalesGroup,MinString(Date) as MinString2  Resident TeamData Group By SalesGroup;` | SalesGroup<br><br>East<br><br>West | MinString2<br><br>01/05/2013<br><br>01062/2013 |