I would like to programatically apply a custom number format so that I can use custom currency symbols in my cells (such as for cryptocurrency) and keep them as numbers so that I can do math with them or chart the values.
I have looked at the following options already:
If I use the spreadsheet function "CONCATENATE", I get a string and cannot do math or chart with the final value.
Spreadsheet function TEXT() can get the number format to display how I want but not all custom currency symbols "work" - the following for instance turns the value into a text string and I cannot do math/charts with it.
Ex: =TEXT(SUM(C5:C7),"Ƀ#,##0.00000000")
reference on TEXT(): https://support.google.com/docs/answer/3094139?hl=en
- If I create a custom function, say
format(cell)
, and use JS to add any text strings to the value, it's no longer a number type.
Ex: function GBP(amt) { return '£' + parseFloat(amt).toFixed(2)); }
This won't work either as resulting string is not a number:
function BTC(amt) { return parseFloat('Ƀ' + parseFloat(amt).toFixed(2)); }
setNumberFormat(format)
cannot be used in a custom function to be called via spreadsheet formulas.Copying another cells formatting? I also see this as a workaround but it looks really not efficient if I have to copy and paste formatting for every cell I want the proper formatting : Applying "Automatic" number formatting
Copying the values into another column just for conditional formatting and the original numbers only range used for maths/charting. This is more a workaround a not a clean solution.
In short, I just want to add custom currency symbols to my numbers and still be able to do math and charts with them. Does anyone know a working, direct way to do so via Google Apps Scripts or spreadsheet functions/menus?
[$Ƀ]#,##0.00000000
? – Robin Gertenbachquery
can do custom formatting without making it as text. You could try using query instead oftext()
in sheets API. – TheMaster