5 Replies Latest reply: Jul 8, 2013 9:40 AM by Steve Lord RSS

    IF conditional problems on select

    Paolo Rena

      Hi to all,

       

      i have a strange problem.

       

      General Issue: when i develope a dashboard on QV 11.2 and i test it on a desktop version all work fine, but when i deploy the dashboard on the server there are problems when i select a value on a field composed of a conditional values.

       

      more deeply:

      i have a field that is 0/1 and i need to decode it with 2 values: NO/YES

      Immagine.png

       

      the expression of a field is: =if(CURRENT_OWNER='1','Yes','No')

       

      USING THE SERVER VERSION QV10 ALL WORKED FINE.

      IN THE QV SERVER 11.2 THERE ARE SOME PROBLEM WHEN I SELECT A VALUES THAT ARE FORMED WITH EXPRESSIONS.

       

      THE PROBLEM IS:

      IN AJAX and Using IE Plugin: if i press No will be selected Yes, if i press Yes will be selected No.

      Immagine2.png

      obvious i need that if i press Yes will be selected Yes.

       

      How is it possible such behaviour if  the formula is just: if(CURRENT_OWNER='1','Yes','No')????

      There are some probls using the new QV11 version? Because with the 10 worked good.

      How can i transform this formula without using if?

       

       

       

      Thanks for your help.

        • Re: IF conditional problems on select
          Steve Lord

          Aside from the apply map or inline load you might try dual if statements to create the field.

           

          if(CURRENT_OWNER='1', Dual('Yes',1),

          if(CURRENT_OWNER='0', Dual('No',2),

          if(CURRENT_OWNER=Null(), Dual('Not Specified',3) as CURRENT_OWNER

           

          The first value in the Dual() function is the text you see in the field on the sheet objects, the second value is how they are sorted.  So your list box would look like

          CURRENT_OWNER

          Yes

          No

          Not Specified

           

          Not sure why, but my list boxes worked properly when I used dual if to create the related field, but acted weird with plain if statements.  If it solidified my list boxes it might make your other items function properly as well.  I quit using plain if statements in my script though they seem fine out in the chart expressions.

           

          Benefit of dual if statement is that you don't need to make separate mapping tables and it is easier to read when handling more complex or convoluted data.  Drawback is (according to a colleague) that if statements take a little more load time than the apply maps- I think the difference is measured in fractions of a second though.  I do believe both the if statements or apply maps (or any other function apply to a field being loaded in script) will slow the load down compared to an unaltered .qvd optimized type load.

            • Re: IF conditional problems on select

              So strange such behaviour,

              but your solution of the dual if work in the server release 11.2

               

               

               

               

              so, thank you so much.

                • Re: IF conditional problems on select
                  Steve Lord

                  I agree your if statement should just do what it says, but I think some background logic in QlikView likes the dual if better for whatever reason.  (Maybe the broader more explicit instruction fills some tiny gap in the background QV logic.)  I had an issue in another post where getCaption in a macro would rather get the object id than the caption and we could only make it get caption by making the object id the same as the caption. ☺  (Super 30k point posters gave the me and the other person right macro syntax, but I had to ascede to QV logic to make the jump from the correct syntax to the desired result.)  It seems to me that the best solutions end up being whichever correct solution QlikView likes the best. ☺