Skip to main content
Sep 10, 2019 8:46 AM UTC
Solved

How to convert datatable's data into Number

As I want to retrieve data from datatable and do calculation with number, how to convert data in the datatable

Oct 13, 2019 3:35 PM UTC

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 

9 replies

Sep 10, 2019 7:00 PM UTC

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

xiaoqwAuthor
Sep 11, 2019 5:58 AM UTC
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

Oct 13, 2019 3:35 PM UTC

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