Skip to main content
1-Visitor
September 10, 2019
Solved

How to convert datatable's data into Number

  • September 10, 2019
  • 1 reply
  • 3288 views

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

Best answer by Constantine

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 

1 reply

Support
September 10, 2019

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

xiaoqw1-VisitorAuthor
1-Visitor
September 11, 2019
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

18-Opal
October 13, 2019

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