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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Merging More than 2 Infotables

agondek
11-Garnet

Merging More than 2 Infotables

I am trying to merge 9 Infotables into one. Right now I am using Union to merge two at a time, then merge the resulting tables together. Does anyone know of a more efficient way to do this? All of the infotables have the same data shape.

var result12 = Resources["InfoTableFunctions"].Union({t1:result1,t2:result2});

var result34=Resources["InfoTableFunctions"].Union({t1:result3,t2:result4});

var result56=Resources["InfoTableFunctions"].Union({t1:result5,t2:result6});

var result78=Resources["InfoTableFunctions"].Union({t1:result7,t2:result8});

var result14=Resources["InfoTableFunctions"].Union({t1:result12,t2:result34});

var result58=Resources["InfoTableFunctions"].Union({t1:result56,t2:result78});

var result18=Resources["InfoTableFunctions"].Union({t1:result14,t2:result58});

var result=Resources["InfoTableFunctions"].Union({t1:result18,t2:result9});

3 REPLIES 3
mgoel
17-Peridot
(To:agondek)

Hi Andrew Gondek

You can refer below existing Knowledge base article and Community Thread to Merge info tables.

How to Merge InfoTables in ThingWorx

How can i merge two infotable and output as one infotable?

Hope it helps.

Regards,

Mohit Goel

agondek
11-Garnet
(To:mgoel)

Hi Mohit Goel

Those articles are where i started exploring this topic and do not answer my question of how to merge more than 2 infotables at a time.

Regards,

Andrew Gondek

Gabriele1986
4-Participant
(To:agondek)

Hi,

Try this, the following works for every vector length.


pip[i] = //your vector of infotables
function mergeDinamic(tab1,tab2){ var params = { t1: tab1, // INFOTABLE t2: tab2 // INFOTABLE }; // result: INFOTABLE var mergeok = Resources["InfoTableFunctions"].Union(params); return mergeok; } var params = { infoTableName : "InfoTable", dataShapeName : "your datashape" }; // CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(DSHP_STREAMSTORICO) var mrgok = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params); for (i=0;i<pip.length;i++) { if (mrgok.length === 0) { if (pip[i] && pip[i+1]) // check if the object exixt { mrgok = mergeDinamic(pip[i],pip[i+1]); i=1; } } else if (mrgok.length > 0) { if( pip[i] ) // check if the object exixt
{ mrgok = mergeDinamic( mrgok , pip[i]); } } } var result = mrgok ; //INFOTABLE with the same datashape



bye

Top Tags