5 Replies Latest reply: May 25, 2012 8:13 AM by Jonathan Dienst RSS

    If and set analysis

    Mats Hedberg

      Hi everyone


      I am having problems excluding selections when using if together with a set analysis like this

      if(_sys_flag_Dag <> 'Igår',

           sum({1<$(sFilterToday)>} [InqueriesCount]),

                sum({1<$(sFilterYD)>} [InqueriesCount])



      Note the 1's that should include all data!


      The expression works well if I don't do any selections but when I select something in the app only that selection displays in the graph (the 1's should prevent this). When I run the expressions one by one (removing the if statement) the selections does not affect the expression!


      Any ideas?


      Many thanks!


        • If and set analysis
          j i

          What's the field you want to exclude? Fro instance, if you want ot exclude the field called "Date" then you should do it like this:


            sum({1<Date=,$(sFilterToday)>} [InqueriesCount]),

          • Re: If and set analysis
            Miguel Angel Baeyens de Arce

            Hi Mats,


            What about something like this instead?


            sum(if(_sys_flag_Dag <> 'Igår', '{1<$(sFilterToday)>}', '{1<$(sFilterYD)>}') [InqueriesCount]))


            You may need to store the whole If() into a variable so it is always evaluated just once and not for each value of the dimension.


            Hope that helps.



              • Re: If and set analysis
                Mats Hedberg

                Hi Miguel


                I have been pondering this a bit and it seems like Qlikview is selecting the data for the if statement and thus overriding the 1 figure in the set analysis.


                I do not know if this is solvable and what I will do is to probably make two graphs on top of each other with one expression each and will then swap between these graphs instead.


                Many thanks!


              • Re: If and set analysis
                Jonathan Dienst



                Perhaps the selections are affecting/limiting the value of your field/variable _sys_flag_Dag possibly indirectly?


                There is no reason that I am aware of the limits you from putting a set expression in an If statement. I do that frequently.