3 Replies Latest reply: Jan 18, 2014 10:39 AM by Manish Kachhia RSS

    lookup function

    manoj kumar

      can anyone explain lookup function

      thanks in advance,

        • Re: lookup function

          Hi,

           

          See the doc I published on LOAD : http://community.qlik.com/docs/DOC-5698

          There is a section on lookup and Applymap functions.

           

          Fabrice

          • Re: lookup function
            Gysbert Wassenaar

            See this document: Joins and Lookups

            • Re: lookup function
              Manish Kachhia

              You can search in QlikView Help File or QlikView Reference Manual for lookup function...


              lookup(fieldname, matchfieldname, matchfieldvalue [, tablename])

              Returns the value of fieldname corresponding to the first occurrence of the value matchfieldvalue in the field matchfieldname.

              Fieldname, matchfieldname and tablename must be given as strings (e.g. quoted literals).

              The search order is load order unless the table is the result of complex operations such as joins, in which case the order is not well defined.

              Both fieldname and matchfieldname must be fields in the same table, specified by tablename. If tablename is omitted the current table is assumed.

              If no match is found, null is returned.

               

              Consider that you have Customer Table having customer information and Sales Table having customer name only.

              You want to lookup customer id or customer country in sales table.

              ===============================================

              Customer:

              Load Text(ID) as ID, Name, Country Inline

              [

                ID, Name, Country

                001, A, Germany

                002, B, Italy

                003, C, France

                004, D, Poland

                005, F, Spain

              ];

               

               

              Sale:

              Load *, Lookup('Country','Name', CustomerName, 'Customer') as Country Inline

              [

                CustomerName, Sale

                A, 100

                B, 200

                C, 300

                D, 260

                E, 140

              ];

               

              Drop Table Customer;

              =============================

              There are another function.... ApplyMap which is used and more fast than lookup but mapping table should have only two columns. One for reference and second as an end result.

               

              Instead of ApplyMap and Lookup, you can join the table also, but sometimes for big database your application get slower and response time increased, so above two functions are handy.

               

              Hope this help....