7 Replies Latest reply: Apr 23, 2016 7:55 AM by Isaac Paz RSS

    Using  Variable with GetFieldSelections()  in the script

    Isaac Paz

      Hi!,

       

      I am trying to create a new table from the filters selected in a sheet and using this variable:

       

      vSelections=GetFieldSelections(machine_PO)

       

      The problem is that the script interprets the variable as: ' GetFieldSelections ( machine_PO )' and not as its text value
      such as ' Machine11 ' .
      I have the following in the load :

      load

      code,

      machine,

      time

      resident Production

      where machine=$(vSelections);

       

      I tried also with ' $ ( vSelections )' but still does not work .


      I am using a qlik sense desktop.

      Any possible solution ?

        • Re: Using  Variable with GetFieldSelections()  in the script
          Stefan Wühl

          GetFieldSelections() is front end only function and can't be used in the script.

           

          So you would need to create a variable that holds the value (and not the function to retrieve the value).

           

          In QV, we could use triggers and an action to set the value 'Machine11' to a variable.

           

          In QS, I don't think we have these means.

           

          Hm, not sure how to resolve this (I still haven't looked very deep into QS).

           

          Maybe mto has a good advice?

          • Re: Using  Variable with GetFieldSelections()  in the script
            Michael Tarallo

            Hi Guys,

             

            Like this ? - see sample attached app.

             

             

             

            You can do this using the new variables interface:

             

            Qlik Sense - Variables Interface (video)

             

            As Stefan pointed out - GetFieldSelections is a client side, object expression - and not meant to be run in the load script.

             

            Please copy .qvf file to your C:\Users\<user profile>\Documents\Qlik\Sense\Apps and refresh Qlik Sense Desktop with F5

             

            Let me know how you do.

             

            Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.

             

            Regards,

            Mike Tarallo

            Qlik

            • Re: Using  Variable with GetFieldSelections()  in the script
              Isaac Paz

              Hi,

               

              Firstly thanks for the answers.

               

              Michael what I really need is to use (vSelection) as a filter in an expression like:

               

              Load

              code,

              machine,

              time

              resident Production

              where machine=$(vSelections);

               

              But as you say , the GetFieldSelections function can not be used in the script. So, I would  need to get a variable with the textual value resulting from (vSelection) .But this is probably not possible.


              Thank you again.

                • Re: Using  Variable with GetFieldSelections()  in the script
                  Michael Tarallo

                  Hi Isaac,  I guess I would need to know more about what you are trying to do, and the usecase. Because technically we don't work like a SQL query tool. All the data is loaded from the source into the app and then is on the fly filtered using the client interface and selection objects in the app. It seems to me you are trying to limit the data loaded into the app based of of a previous selection. This still may be possible, but I am not sure how - I added a colleague, whom if he has a moment might respond as well.

                   

                  jpe

                • Re: Using  Variable with GetFieldSelections()  in the script
                  Isaac Paz

                  Hi,

                  I will try to expose the use case in question.
                  From a main table ( Production) , with the following fields :
                  Codigo_OP ( Orden Produccion )
                  Machine ( Maquina )
                  Item ( Pieza)
                  RealBegin(Fecha Inicio Seleccion)
                  RealEnd(Fecha Fin Seleccion)
                  I create another new table ( Production_timeline ) only with machines that have worked within the specified date range , using for this the Reload extension.
                  ( This is necessary because google api I'm using does not allow Measures )

                  Then the table ( Production_timeline ) is shown in the timeline and chart table.
                  Well, what the customer really wants is to select date range and machine and make a new reload with those filters and for this I need to know which machine is selecting , but  with GetFieldSelections () as you have said is not possible.

                  I hope I explained , but ask me anything.

                  Thanks again for allscreen.PNG