# alt - script and chart function

The alt function returns the first of the parameters that has a valid number representation. If no such match is found, the last parameter will be returned. Any number of parameters can be used.

Syntax:

alt(expr1[ , expr2 , expr3 , ...] , else)

Arguments:

Arguments

| Argument | Description |
| --- | --- |
| expr1 | The first expression to check for a valid number representation. |
| expr2 | The second expression to check for a valid number representation. |
| expr3 | The third expression to check for a valid number representation. |
| else | Value to return if none of the previous parameters has a valid number representation. |

The alt function is often used with number or date interpretation functions. This way, Qlik Sense can test different date formats in a prioritized order. It can also be used to handle NULL values in numerical expressions.

Examples:

Examples

| Example | Result |
| --- | --- |
| `alt( date#(<br>						dat , 'YYYY/MM/DD' ),`<br>`date#( dat<br>						, 'MM/DD/YYYY' ),`<br>`date#( dat<br>						, 'MM/DD/YY' ),`<br>`'No valid<br>						date' )` | This expression will test if the field date contains a date according to any of the three<br>specified date formats. If so, it will return a dual value containing the original string and<br>a valid number representation of a date. If no match is found, the text<br>'No valid date' will be returned (without any valid number representation). |
| `alt(Sales,0) + alt(Margin,0)` | This expression adds the fields Sales and Margin, replacing any missing value (NULL) with a 0. |