Maximum Value of a Table Column (Math.max)

Hi,

i need the max value of a table Column.
I tried:

{{
function(){
var data = Tablehistory.tableData.map(o => o.POSTDATE);
var max = Math.max(data);
return max;
}
()}}

the values of “data” is:
[
1608046722427,
1637580142400,
1637580142400,
1652892338417,
1652892338417,
1608046722427,
1608046722427,
1608046722427,
1637580142400,
1637580142400,
1637580142400,
1652892338417,
1652892338417,
1608046722427,
1608046722427,
1608046722427,
1608046722427,
1637580142400,
1637580142400
]

But max result is “NaN”

Still JavaScript hates me :sleepy:

Can anyone help me ?
thx

Franz

Hi Franz,

Please try Math.max(...data) instead of Math.max(data)
This should work:

{{
function(){
var data = Tablehistory.tableData.map(o => o.POSTDATE);
var max = Math.max(...data);
return max;
}
()}}
1 Like

Hi Amelia,

thank you, the result with Math.max(...data) is -Infinity ??

i expect a different result.

Franz

Hi,
i refreshed the Appsmith window and tried again, and the result is fine.
that’s weird.

Franz