Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts,
What is Alt Function ? where we have to use?
Find information about Alt function from Qlik Sense Help: https://help.qlik.com/sense/2.0/en-US/online/#../Subsystems/Hub/Content/Scripting/ConditionalFunctio...
Alt function will attempt to iron out variances in number formatting when you can't predict a uniformity in a data source or multiple data sources.
For example, I used this significantly for a recent app in that was collating flat files from a variety of topics | locations | formats.
What the alt function does is say "try this date|time|number format. Did it evaluate to a number? Nope. Ok, try the next format. Did that evaluate to a number? Nope. Ok, try the next format." And so on...
So let's say my log files turned out to store data in a variety of date formats. What alt can help you test is a match for all different anticipated types:
LOAD
alt(
date#(DATE_FIELD,'MM/DD/YYYY'),
date#(DATE_FIELD,'MM-DD-YYYY'),
date#(DATE_FIELD,'YYYYMMDD'),
date#(DATE_FIELD,'YYYY-MM-DD')
) AS [SO_HELP_ME_I_AM_SQUEEZING_A_DATE_OUT_OF_THIS_FIELD_IF_I_HAVE_TO_TEST_FOR_EVERY_PERMUTATION_EVER]
FROM LogFile.txt (txt);
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: