Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
As I want to retrieve data from datatable and do calculation with number, how to convert data in the datatable
Solved! Go to Solution.
Hello @xiaoqw ,
RenameField returns an INFOTABLE and not an INTEGER, so you probably want to do something like this:
var result = parseInt(output.value);
// or
var result = parseInt(output.rows[0].value);
/ Constantine
Hi @xiaoqw.
Are you trying to convert existing data in the table? We tested using a string value and were able to perform calculations on it without the need to convert the data type. If your scenario is different you could try running the parseInt() function.
If you still have issues, please provide specifics of your datatable so we can test further.
Regards.
--Sharon
var output = Resources["InfoTableFunctions"].RenameField({
t: Resources["InfoTableFunctions"].Aggregate({
t: me.QueryDataTableEntries({ maxItems: undefined,
query: query,
values:undefined,
source: undefined,
tags:undefined
}),
columns: 'value',
aggregates: 'SUM',
groupByColumns: 'value'
}),
from: "SUM_value",
to: "value"
});
var result = parseInt(output);
here is my code and output should be number but now is NaN. Please take a look and give me suggestion how to edit
Hello @xiaoqw ,
RenameField returns an INFOTABLE and not an INTEGER, so you probably want to do something like this:
var result = parseInt(output.value);
// or
var result = parseInt(output.rows[0].value);
/ Constantine
Hi @xiaoqw.
The query has not been defined, so we're not clear on what you are trying to do. It also looks like you're attempting to rename a field. Is this your intent?
We can't tell what kind of data you have in your datatable from the sample code you provided, so need more information to be able to assist.
Regards.
--Sharon
hello slangley,
I need to do SUM aggregation function first and get the sum value.
after that, I will use SUM value to do a calculation. so how should I put formula on this service.
And my query is filter function. to filter data from datatable.
Hi @slangley ,
I need to do SUM aggregation function first and get the sum value.
after that, I will use SUM value to do a calculation. so how should I put formula on this service.
Hi @xiaoqw.
Can you either copy the full code for the service, or export the thing containing the service so we can see better what you are trying to do?
Regards.
--Sharon