Category: JavaScript
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Maximum Value of a Table Column (Math.max)

Issue

I was trying to find the maximum value of a column in a table using JavaScript in Appsmith. I used Math.max(data), but it resulted in "NaN". I asked for help and was advised to use Math.max(...data) instead. However, the first result was still wrong, but after refreshing the window and trying again, it worked fine. It was quite weird.

Resolution

The user was trying to find the maximum value of a column in a table using the Math.max() function in JavaScript. However, they were getting a NaN result. Another user suggested using Math.max(...data) which spreads the array, and that worked correctly.

The user encountered a strange issue where the result was -Infinity. However, after refreshing the Appsmith window and trying again, the correct result was returned. The solution was to use Math.max(...data) to find the maximum value of the table column.