cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Regarding DeriveFields

Bhanu_Manoj
9-Granite

Regarding DeriveFields

Hi Team,

 

How can I use DeriveFields on an infotable? I have an infotable as shown below.

 

col1 col2
test name.hai
test2 name.hello
test3 name.hai
test4 name.hello
test5 hello

 

I want new infotable to me without the string "name." in the col2 field. The new col2 should have hai , hello only.

 

Regards,

1 ACCEPTED SOLUTION

Accepted Solutions

var params = {
types: "STRING"/* STRING */,
t: YOURINFOTABLENAME /* INFOTABLE */,
columns: NEWCOLUMNNAME/* STRING */,
expressions: col2.split(".")[1]/* STRING */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].DeriveFields(params);

 

View solution in original post

5 REPLIES 5
PaiChung
22-Sapphire I
(To:Bhanu_Manoj)

Not sure if this helps

https://community.ptc.com/t5/IoT-Tech-Tips/Powerful-Things-you-can-do-with-DeriveFields/m-p/535264

To remove the column, you can just drop the column from the infotable or not include it in the datashape in your output or just carry it but ignore it.

Hi Pai,

 

Firstly thanks for the reply. My question is that I have to process the col2 data and remove some part of string from all the rows of col2. Can you let me know how can I proceed?

 

can you please let me know what these fields do or any example usage link.

 


var params = {
types: undefined /* STRING */,
t: undefined /* INFOTABLE */,
columns: undefined /* STRING */,
expressions: undefined /* STRING */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].DeriveFields(params);

 

 

var params = {
types: "STRING"/* STRING */,
t: YOURINFOTABLENAME /* INFOTABLE */,
columns: NEWCOLUMNNAME/* STRING */,
expressions: col2.split(".")[1]/* STRING */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].DeriveFields(params);

 

PaiChung
22-Sapphire I
(To:abhiramk)

Just a minor note, the expression has to be a string so maybe

expressions: 'col2.split(".")[1]'/* STRING */

 

instead. or 

 

expressions: "col2.split('.')[1]"/* STRING */

 

Always a bit of a pain when you have to work with an actual 'string' item in this expression field.

slangley
23-Emerald II
(To:Bhanu_Manoj)

Hi @Bhanu_Manoj.

 

If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Top Tags