Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
here is my coding which I want to do calculation using datatable data. output should be "NUMBER". but now result is NaN. Could someone help me figure it out?
var query =
{
"filters": {
"type": "And",
"filters": [
{
"type": "EQ",
"fieldName": "Department",
"value": "Milk"
},
{
"type": "EQ",
"fieldName": "Kategory",
"value": "Production Volume"
}
]
}
};
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/10000);
Solved! Go to Solution.
var result = parseInt(output/10000);
It looks like you are trying to divide the whole infotable? maybe
var result = parseInt(output.value/10000);
BTW it seems redundant to rename the field, not sure if you are trying to use the infotable somewhere else as well.
var result = parseInt(output/10000);
It looks like you are trying to divide the whole infotable? maybe
var result = parseInt(output.value/10000);
BTW it seems redundant to rename the field, not sure if you are trying to use the infotable somewhere else as well.
Thank you for your help. it works!!!
Hello Tracy,
Thank you for reaching out on the ThingWorx Developers Community.
I did some quick testing with the code provided and I believe you can achieve the desired results by changing the last line to the following:
var result = parseInt(output.value/10000);
When you call for output only the return is an Infotable. If you call for output.value you specifically get the single number from the value field.
Please let me know if this is helpful.
Regards,
Tyler Misner
ThingWorx Technical Support Engineer
Anyway thank you for you testing my code!! And thank you Thingworx Developers Community