Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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,
Solved! Go to Solution.
var params = {
types: "STRING"/* STRING */,
t: YOURINFOTABLENAME /* INFOTABLE */,
columns: NEWCOLUMNNAME/* STRING */,
expressions: col2.split(".")[1]/* STRING */
};
// result: INFOTABLE
var result = Resources["InfoTableFunctions"].DeriveFields(params);
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);
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.
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