6 Replies Latest reply: Aug 17, 2017 1:42 AM by Dafnis X RSS

    Applymap with FieldName

    Dafnis X

      Hi,

       

      I would like to use ApplyMap by the FieldName, to some fields.

      For example:

      ApplyMap('Map_FieldCode', FieldName(nr ,'TableName'))

      Is it possible?

       

      I thought of using a loop, but something is going wrong while trying to  create the new table.

       

      OpenPurchOrder:

      LOAD Distinct PurchOrder_LineID,

      PurchOrder_Line_DepartDate,

      PurchOrder_Line_SupplyDate,

      from $(vQVDPath)PurchOrder.QVD (qvd)

      Where PurchOrder_Flag_IsClosed =0;

       

       

      LET NF = NoOfFields('OpenPurchOrder');

      LET NR = NoOfRows('OpenPurchOrder');

       

       

      FOR I = 1 TO $(NR)

       

      FOR J = 1 to $(NF)

      TmpTable:

      LOAD FieldName($(J),'OpenPurchOrder');

       

      NEXT

       

      NEXT

       

      Thanks!

        • Re: Applymap with FieldName
          Oleg Troyansky

          Hi Dafnis,

           

          can you explain what are you trying to accomplish, in simple words? Are you mapping field names or field values? how does your mapping table look like?

           

          Cheers,

          Oleg Troyansky

          Upgrade your Qlik skills at the Masters Summit for Qlik - coming to Boston, MA this October!

            • Re: Applymap with FieldName
              Dafnis X

              Hi Oleg,

               

              I'm trying to map a value by the  QVD field name:

                

              QVD_FieldNameMetric_Code
              PurchOrder_Line_DepartDate2
              PurchOrder_Line_SupplyDate3
              PurchOrder_Line_Flag_SuppDateIsConf4

               

              Thank you!

                • Re: Applymap with FieldName
                  Oleg Troyansky

                  Sorry, still missing the point... Maybe if you describe your source data and the desired result, it could become clearer...

                    • Re: Applymap with FieldName
                      Dafnis X

                      Yes, I realize that...

                       

                      This is the base table:

                      OpenPurchOrder:

                      LOAD Distinct PurchOrder_LineID,

                      PurchOrder_Line_DepartDate,

                      PurchOrder_Line_SupplyDate,

                      from $(vQVDPath)PurchOrder.QVD (qvd)

                      Where PurchOrder_Flag_IsClosed =0;

                       

                      I would like to link  metric code to some of the fields. 

                      The mapping is based on the field name.

                       

                      Otherwise, i have to write it in the script:

                      For example:

                      .......

                      Concatenate (MissingDates)

                      LOAD PurchOrder_LineID as Tmp_LineID,

                      PurchOrder_No as Tmp_PurchOrder_No,

                      2 as Tmp_MetricCode

                      Resident OpenPurchOrders

                      Where Year(PurchOrder_Line_DepartDate) =1988;

                       

                      Concatenate (MissingDates)

                      LOAD PurchOrder_LineID as Tmp_LineID,

                      PurchOrder_No as Tmp_PurchOrder_No,

                      3 as Tmp_MetricCode,

                      Resident OpenPurchOrders

                      Where Year(PurchOrder_Line_SupplyDate) =1988;