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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

infotable pivot

effpt3
13-Aquamarine

infotable pivot

I have an infotable which conatins timestamp, device_name, temp columns.

I need to apply pivot inorder to get device_names as fields w.r.t temp column as values.

My pivot code is:

var params = {
t: data /* INFOTABLE */,
nameColumn: "DEV_NAME" /* STRING */,
valueColumn: "temp"/* STRING */,
timestampColumn: "timestamp" /* STRING */
};

var result = Resources["InfoTableFunctions"].Pivot(params);

 

and i'm getting error like this:

{
"error": ""
}

 

please help me out...

3 REPLIES 3
serler
12-Amethyst
(To:effpt3)

I reproduced your pivot question and for me it works without a problem.

That is the infotable, which I used as a basis:

2019-05-06_10-12-49.png

After executing the service I got the following result:

2019-05-06_10-21-32.png

I guess that meets you expectations.

 

Can you please check - name column attribute. (You were writing "DEV_NAME", but mentioned in your text above device_name)

A second thing you could check is the output of the service, that this is set to infotable. (As I cannot see that from your description)

effpt3
13-Aquamarine
(To:serler)

Hi @serler 

Thank you for responding.

I have checked my column names. Those are right.

I am getting valuecolumn from a switch case. please follow the below full code 

 

 

// result: INFOTABLE dataShape: ""
var data = me.QueryPropertyHistory({
oldestFirst: undefined /* BOOLEAN */,
maxItems: undefined /* NUMBER */,
endDate: undefined /* DATETIME */,
query: undefined /* QUERY */,
startDate: undefined /* DATETIME */
});

var value_col;
switch(parameter_name){
case "TEMP" :
data.RemoveField("HUMD");
data.RemoveField("CO2");
data.RemoveField("VOCtvoceq");
data.RemoveField("VOCco2eq");
data.RemoveField("DUST_PM2_5");
data.RemoveField("DUST_PM10");
data.RemoveField("DEV_ID");
value_col = "TEMP";
break;

case "HUMD" :
data.RemoveField("TEMP");
data.RemoveField("CO2");
data.RemoveField("VOCtvoceq");
data.RemoveField("VOCco2eq");
data.RemoveField("DUST_PM2_5");
data.RemoveField("DUST_PM10");
data.RemoveField("DEV_ID");
value_col = "HUMD";
break;
case "CO2" :
data.RemoveField("TEMP");
data.RemoveField("HUMD");
data.RemoveField("VOCtvoceq");
data.RemoveField("VOCco2eq");
data.RemoveField("DUST_PM2_5");
data.RemoveField("DUST_PM10");
data.RemoveField("DEV_ID");
value_col = "CO2";
break;
case "VOCtvoceq" :
data.RemoveField("TEMP");
data.RemoveField("CO2");
data.RemoveField("HUMD");
data.RemoveField("VOCco2eq");
data.RemoveField("DUST_PM2_5");
data.RemoveField("DUST_PM10");
data.RemoveField("DEV_ID");
value_col = "VOCtvoceq";
break;
case "VOCco2eq" :
data.RemoveField("TEMP");
data.RemoveField("CO2");
data.RemoveField("VOCtvoceq");
data.RemoveField("HUMD");
data.RemoveField("DUST_PM2_5");
data.RemoveField("DUST_PM10");
data.RemoveField("DEV_ID");
value_col = "VOCco2eq";
break;
case "DUST_PM2_5" :
data.RemoveField("TEMP");
data.RemoveField("CO2");
data.RemoveField("VOCtvoceq");
data.RemoveField("VOCco2eq");
data.RemoveField("HUMD");
data.RemoveField("DUST_PM10");
data.RemoveField("DEV_ID");
value_col = "DUST_PM2_5";
break;
case "DUST_PM10" :
data.RemoveField("TEMP");
data.RemoveField("CO2");
data.RemoveField("VOCtvoceq");
data.RemoveField("VOCco2eq");
data.RemoveField("DUST_PM2_5");
data.RemoveField("HUMD");
data.RemoveField("DEV_ID");
value_col = "DUST_PM10";
break;
}

var params2={
t: data /* INFOTABLE */,
nameColumn: "DEV_NAME" /* STRING */,
valueColumn: value_col/* STRING */,
timestampColumn: "timestamp" /* STRING */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Pivot(params2);

 

serler
12-Amethyst
(To:effpt3)

based on the information you provided I cannot see anything, which would cause the error in Pivot, sorry.

Announcements


Top Tags