Search code examples
jsonjsonata

I'n JSON how to display 10000 as 10 K .{data;10000}


I'n JSON how to display 10000 as 10 K .{data;10000}

I'n JSON how to display 10000 as 10 K .{data;10000} how to display as unit if 1000 means 1k 10000 means 10 k


Solution

  • I don't think $formatNumber supports it out of the box (check the docs for more info: https://docs.jsonata.org/numeric-functions#formatnumber)

    But if you only ever display thousands there - you can divide the number by 1000 yourself and then format it:

    $formatNumber(value / 1000, "#K")
    

    On the playground: https://stedi.link/mkATNe7