Compact or custom float format

Answered
Foivos Theocharis asked on April 5, 2022

Hi Flexmonster support team,
We have gone through the documentation and examples for number formatting:
https://www.flexmonster.com/doc/number-formatting/
https://www.flexmonster.com/examples/#number-formatting
But we cannot find how to specify a compact format, such as:

  • 123,456 turning into 123k
  • 123,456,789 into 123m

Is that currently possible? If not, can you please add this capability to the formatting system? Or, alternatively, the ability to format numbers using custom (e.g. javascript) code?
Thanks in advance!

1 answer

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 5, 2022

Hi, Foivos!

Thank you for reaching out to us.

Flexmonster provides an ability to format cells through JavaScript code. This can be done via customizeCell API call. We recommend the following approach to create a formatting similar to the one described in your question:

  • Access the value inside the cell using data.value property.
  • Pass the value to a custom formatting function that will transform the number to a string with K or M, depending on the number's size. 
  • Replace the cell.text property with a resulting string.

You are welcome to check out our implementation of this approach: https://jsfiddle.net/flexmonster/n7Ljc4xq/.

Please let us know if such an approach would work for your case. Looking forward to your response.

Best Regards,
Maksym

Please login or Register to Submit Answer