Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
for date here pag 7
other I sometimes use: when I want to change a null() to a default or 0
alt ($(var), 0)
useful link
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.
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