3 Replies Latest reply: May 16, 2017 11:35 AM by Enikö  Karlecz RSS

    Pass Parameter into Qlik Function

    Enikö  Karlecz

      Hi,

       

      I want to define an eExpression, with a Parameter to deciced the "rank'" - so if I want the 1st or 2nd or 3rd  - sorted value:

      =FirstSortedValue(Field, SortWeight, $1)

       

      The real expression is this, works ok if I use a number or nothing for the 3rd Param.

      =FirstSortedValue( TOTAL   DIM1&';'&DIM2, 
      -Aggr(  

      $(eZZZ) / $(eYYY_0) +
      $(eZZZ) / $(eYYY_1) +
      $(eZZZ) / $(eYYY_2)
                        , DIM1,  DIM2)  
           ,$1
           )

       

      Thanks! Hope I can do this :-)

        • Re: Pass Parameter into Qlik Function
          omar bensalem

          Well you can add a variable maybe?

          Let's call it : vParam :

           

          Capture.PNG

          Capture.PNG

           

          As an expression :

          =' number '&(vParam)& ' is : '&FirstSortedValue(id, -sales, $(vParam))

          • Re: Pass Parameter into Qlik Function
            Enikö  Karlecz

            I made it working, the issue was not with the Parameter but the eExpression definition:

             

            =FirstSortedValue(TOTAL Field, SortWeight, $1) not OK,  if used in chart or textbox like: '$(FirstSortedExpr(2))'

             

            =FirstSortedValue(TOTAL Field, SortWeight, 2)  OK if used in chart or textbox like: '$(FirstSortedExpr)'

             

            FirstSortedValue(TOTAL Field, SortWeight, $1) OK,  if used in chart or textbox like: $(FirstSortedExpr(2))

             

            So I assume it must be that in the above examples, the Expression was calculated 'in the background' (first) and its result delivered as a string.

            In the 3rd, the Expression is only calculated in the front end object with the passed paramter.

             

            Any feedback / affaimation on this would be appreciated...  Thanks!