Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
prabhas277
Creator
Creator

Alt function

Hi,

What is the use of alt function? Give one example?

Thanks in Advance

1 Solution

Accepted Solutions
robert_mika
Master III
Master III

Alt belongs to Conditional function (like extended IF function) returning first numerical value.

In this case 1 is returned

in this 2

and so on..

If no number is found the last value is returned:

View solution in original post

11 Replies
avinashelite

Hi,

Please refer this:

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).

robert_mika
Master III
Master III

Alt belongs to Conditional function (like extended IF function) returning first numerical value.

In this case 1 is returned

in this 2

and so on..

If no number is found the last value is returned:

Not applicable

Hi @prabhas v

Check this THREAD below

Which conditional functions do you use?

In this Thread Use of ALT Function is Explained in detail check this

Thanks & Regards

NK

jagan
Luminary Alumni
Luminary Alumni

Hi,

It is similar to NVL() in Oracle, ISNULL() in SQL Server.

If the first parameter returns null then the second parameter value is assigned.

Alt(Sum(Sales), 0) 

If Sum(Sales) is null then 0 is returned

Alt(Only(Year), Year(Today())) - If Only(Year) returned null then Current year is assigned to it.

Also you can multiple levels in this which is similar If-elseif-else or Case statement

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

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

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

'No valid date' )

Regards,

Jagan.

Not applicable

Hi Robert,

I have a scenario that i need to convert the if condition expression into Alt finction

if(IF(GetFieldSelections(Earlypayment) = 'NEFT' AND Payment_Discount<>0 ,1,0)=1, Discountperday * PaymentFunds  ,0)

I tried like this,

=Alt(IF(GetFieldSelections(Earlypayment) = 'NEFT' AND Payment_Discount<>0 ,1,0)=1, Discountperday * PaymentFunds  ,0)

Chanty4u
MVP
MVP

chk dis

Alt Function

Anil_Babu_Samineni

Nice Explanation...

I like this

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
chiranjeevialapati
Contributor
Contributor

Very Nice Explanation.