Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

alt fun?

Hi i am fully confused with

can any one explain me with simple examples and

in how many ways we will use alt function?

4 Replies
buzzy996
Master II
Master II

alt( case1 [ , case2 , case3 , ...] , otherwise )

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.

Example:

alt( date#( dat,'YYYY/MM/DD' ),

date#( dat,'MM/DD/YYYY' ),

date#( dat,'MM/DD/YY' ),

'No valid date' )

will test if the variable dat contains a date according to any of the

three specified date formats. If so, it will return the original string

and a valid number representation of a date. If no match is found,

the text 'No valid

qv_testing
Specialist II
Specialist II

HI,


Example:

Alt('ABC',12,13,'jkl')

Here it will return 12,

Alt() function returns first numeric value.... If you don't have any numeric value,

it will return last parameter (Means last string)

Example:

Alt('ABC', 'KL', 'NM', 'Comm')

returns Comm

Here, we don't have any numeric value, that's why return last parameter...

Hope it Helps...

Digvijay_Singh

One of the critical use is, when you are not sure your expression may or may not result NULL value, and you want to avoid null and consider 0 for such unavoidable cases. So we use Alt(<expression>,0). In normal cases expression results numeric value and that will be the output of alt function but due to any unavoidable reasons(like divide by zero etc) if expression results null then 0 will be the output.

Anonymous
Not applicable
Author

hi,

Alt(case1[ , case2 , case3 , ...] , else)
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.
Example:
alt( date#( dat , 'YYYY/MM/DD' ),
date#( dat , 'MM/DD/YYYY' ),
date#( dat , 'MM/DD/YY' ),
'No valid date' )

Will test if the field date contains a date according to any of the three specified date formats. If so, it will return the original string and a valid number representation of a date. If no match is found, the text 'No valid date' will be returned (without any valid number representation).


please check below post:


Re: Alt function

Which conditional functions do you use?