13 Replies Latest reply: May 5, 2014 11:02 AM by Madhu Reddy RSS

    how to use first function in qlikview?

      hi guys,

      I created table box in qlikview.I want to select first 4 employees in that table box  so that I use First () function in script but the first () function did not work .I do not know how to use FIRST() function in qlikview.Please tell me out  how to useFIRST() function in qlikview.

      I attached snipping file below this box.

      Regards:

      madhu

        • Re: how to use first function in qlikview?
          Massimo Grossi

          to only load 4 rows

           

          table:

          first 4 LOAD

               *

          from sometable;

          • Re: how to use first function in qlikview?
            Joseph Musekura

            Hi

             

            you don't need () when using first

            See attached: click table viewer, each table has 4 rows only

             

            Regards

            • Re: how to use first function in qlikview?
              Joseph Musekura


              Hi,

               

              There is another context when using First() or Last(). See below from QlikView reference manual :

               

              first([ total ] expression [ , offset [,n ]])

               

              Returns the value of expression evaluated with a pivot table's dimension values as they appear in the first column of the current row segment in the pivot table. This function returns NULL in all chart types except pivot tables. 

              If the table is one-dimensional or if the expression is preceded by the total qualifier, the current row segment is always equal to the entire row.

               

              If the pivot table has multiple horizontal dimensions, the current row segment will include only columns with the same values as the current column in all dimension rows except for the row showing the last horizontal dimension of the inter field sort order. The inter field sort order for horizontal dimensions in pivot tables is defined simply by the order of the dimensions from top to bottom.

               

              Specifying an offset greater than 1 lets you move the evaluation of expression to columns further to the right of the first column. A negative offset number will actually make the first function equivalent to a last function with the corresponding positive offset number. Recursive calls will return NULL.

               

              By specifying a third parameter n greater than 1, the function will return not one but a range of n values, one for each of the first n columns of the current row segment. In this form, the function can be used as an argument to
              any of the special Chart
              Range Functions
              .

               

              Examples:

              first( sum( Sales ))

              first( sum( Sales ), 2 )

              first( total sum( Sales )

               

              rangeavg (first(sum(x),1,5))returns an average of the results of the sum(x)
              function evaluated on the five leftmost columns of the current row segment.

               

               

               

              last([ total ] expression [ , offset [,n ]])

               

              Returns the value of expression evaluated with a pivot table's dimension values as they appear in the last column of the current row segment in the pivot table. This function returns NULL in all chart types except pivot tables. 

              If the table is one-dimensional or if the expression is preceded by the total qualifier, the current row segment is always equal to the entire row.

               

              If the pivot table has multiple horizontal dimensions, the current row segment will include only columns with the same values as the current column in all dimension rows except for the row showing the last horizontal dimension of the inter field sort order. The inter field sort order for horizontal dimensions in pivot tables is defined simply by the order of the dimensions from top to bottom.

               

              Specifying an offset greater than 1 lets you move the evaluation of expression to columns further to the
              left of the last column. A negative offset number will actually make the last function equivalent to a first function with the corresponding positive offset number. Recursive calls will return NULL.

               

              By specifying a third parameter n greater than 1, the function will return not one but a range of n
              values, one for each of the last n columns of the current row segment. In this form, the function can be used as an argument to any of the special Chart
              Range Functions
              .

               

              Examples:

              last( sum( Sales ))

              last( sum( Sales ), 2 )

              last( total sum( Sales )

               

              rangeavg (last(sum(x),1,5))returns an average of the results of the sum(x)
              function evaluated on the five rightmost columns of the current row segment.
              • Re: how to use first function in qlikview?
                Anand Chouhan

                You can write some thing like below script for First 4 and load another resident table for this also you can do this with existing but you can try below script.

                 

                Employees:

                LOAD Empkey,

                  Employname,

                  salary

                FROM

                [d:\madhu\Data\Salary.xlsx]

                (ooxml, embedded labels, Table is Sheetl);

                 

                NoConcatenate

                First 4

                LOAD *

                Resident Employees;

                 

                DROP Table Employees;

                • Re: how to use first function in qlikview?
                  Marco Wedel

                  Hi madhu,

                   

                  if you just want to show the first four employees in a table then you might also use a straight table instead of a table box and limit the dimensions like this:

                   

                  QlikCommunity_Thread_117124_Pic1.JPG.jpg

                  QlikCommunity_Thread_117124_Pic2.JPG.jpg

                  regards

                   

                  Marco