Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
dafnis14
Specialist
Specialist

Applymap with FieldName

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!

6 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

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!

dafnis14
Specialist
Specialist
Author

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!

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

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

dafnis14
Specialist
Specialist
Author

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;

qliksus
Specialist II
Specialist II

You can try something like the below

Let  vMetriccode = '1,2,3';

LOAD PurchOrder_LineID as Tmp_LineID,

PurchOrder_No as Tmp_PurchOrder_No,

subfield('$(vMetriccode)',',') as Tmp_MetricCode

Resident OpenPurchOrders

Where Year(PurchOrder_Line_DepartDate) =1988;

And then use applymap on Tmp_MetricCode

dafnis14
Specialist
Specialist
Author

Hi,

Sorry for my late response...

Please note that for each metric I check another field (DepartDate, SuppluDate, etc..)

So i'm not sure how i should apply your solution.

Thank You!