6 Replies Latest reply: May 13, 2015 10:22 AM by Drunda Nibel RSS

    changing messure formula dynamically

      Hi,

       

      in my Qlik Sense Desktop app I use a messure, whose formula should change depending on the state of a switch (extension "VariableButton"). The switch can be connected to a variable (i.e. vSwitch_on_off). Fortunately it is very easy to change the value of that switch ("on" or "off" / 1 or 0) each other in the field "Button value 1":

      =IF(vSwitch_on_off = 0, 1, 0)

       

      Now I want to create a second variable vMessure in my script, whose value would change depending on the state of that switch. This variable could dynamically evaluate in my app calling the syntax $(vMessure).

       

      Anyway, my Problem is: How is the syntax for that part of the script, where I have to assign the formula to the messure variable? I tried this, but without success:

       

      sub create_messure_formula (vSwitch_state)

        if vSwitch_state = 0 then

          vMessure = field1

        else

          vMessure = field2

        endif

      end sub

       

      LET vMessure = 'call create_messure_formula (vSwitch_on_off)';


      How to get ready? Any help is appreciated!

      Thanks and regards!