Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

alt() uses?

alt(case1[ , case2 , case3 , ...] , else) alt function can returns the first of the  parameter that has valid number presentation its ok. i have doubt ,it is  use for  only date or any other number  give me one scenario.



Thanks

Madhu





4 Replies
marcus_sommer

It's for all cases where you mandatory needs a valid result from an expression - for this is the else-part where you could determine your default-value. For example if you need a division like:

sum(value1) / alt(sum(value2), 1)

then if sum(value2) is 0 or NULL the whole expression will be NULL unless you caught some unwanted and invalid results with alt() or in other cases with a range-function. It avoids to catch such things with if-loops.

- Marcus

maxgro
MVP
MVP

for date here pag 7

QlikView Date fields

other I sometimes use: when I want to change a null() to a default or 0

alt ($(var), 0)

useful link

What are the Peek() and Alt() functions used for?

Alt function

jagan
Luminary Alumni
Luminary Alumni

Hi,

The best example is, suppose is you have a date field with multiple formats then Alt() comes handy to convert it into a common format

For example

LOAD

*

INLINE [

Date

1/1/2015

1-Jan-2015

2015-Jan-1];

Now using Alt() we can convert to a common format like below

LOAD

Date(Alt(Date#(Date, 'D-MMM-YYYY'), Date#(Date, 'YYYY-MMM-D'), Date#(Date, 'M/D/YYYY'))) AS Date_Formatted

INLINE [

Date

1/1/2015

1-Dec-2015

2015-Sep-1];

Hope this helps you.

Regards,

jagan.

beck_bakytbek
Master
Master

Hi Josna,

to issue: Alt () function:

it is important to insure that the Default value that you want is the second value in the function, otherwise that will become the first value and will override the value that you want. When using this in script, you should be sure that the value is definitely numeric or it may always be the Default value. if it is numbers that are expressed as text, you can use the num# function to make sure that they are seen as numbers.

if you want to have an example to this issue, let me know, then i send you my example

i hope that helps

kindly

Beck