A workaround to achieve this for display
Assuming that the number is in A1, a “display version” of the number as text can be achieved by the following fomula:
=IF(A1<0,"-","")&TEXT(INT(ABS(A1)),"#,##0")®EX(REGEX(TEXT(MOD(ABS(A1),1),".#################"),"([:digit:]{3})","$1\,","g"),"\,$","")
some explanation
- The initial IF() and the instances of ABS() are together required if you need to handle negative numbers. The MOD() function is correct and predictable in its handling of negatives, but not always intuitive
- The integer part is easily formatted as desired.
- The fraction part extracted by “modulo 1” calculation and preformatted without any leading zero.
- The inner REGEX() inserts comma to the fraction part after every 3 digits.
- The outer REGEX() removes a trailing comma which will otherwise occur when decimal count is a multiple of 3.
This was the simplest I could make it while catering for negative numbers, large numbers and an arbitrary number of decimals. (Just add # characters to allow for more decimals.)
Please note:
- The output from this formula is text, which is by default aligned left. Use cell formatting (style) for proper alignment.
- As already determined, this number formatting layout is not supported by Calc, so the output is not reliably interpreted by the VALUE() function. Use the source value for further calculations. This workaround only serves display purposes.