You can "Alt" it

    I came across an interesting function "Alt".

     

    Yes. Its Alt.

     

    * For those who haven't come across this function.

     

    It gives the fist number among the values it read.

     

    alt('x',1,2) - This basically returns 1.

     

    Qlik Help has enough description on this.

     

    Advantage: If you want to check for isnum and then want to replace a value like 1 or 0 if the value is not a number, rather than using an "IF CONDITION", this can help.

     

    Attached is the qvw with an example.

     

    For the date 2013-02-01, I don't have an exchange rate. So, if no exchange rate is updated, the product shows 0 which is technically correct but the desired result for a user might not be this.

     

    If no exchange rate is updated,I want to show the Sales as is.

     

    Here, I need not go for an if condition to check if Exchange Rate don't have any value, the Sales should be multiplied with 1.

     

    Instead of using an if condition to check if there's a value, I can go for Alt.

     

    sum(LocalSales*Alt(ExRate,1)).

     

    Whenever ExRate doesn't have any number in it, 1 is replaced.

     

     

     

    Cheers,

    Naresh

    Alt.qvw (148.2 K) Download