Column format as a way to deal with floating point errors

As a way to avoid the limitation of Coda of not supporting decimals (pretty important for anything related to accounting), I was trying to use integers representing cents instead, so that any comparisons and calculations could be done with integers.

Then I was trying to use a column format to display the minor currency integer value, e.g. 43350, as $433.50. I ran into 2 problems - is there a solution?

  1. As soon as the column is using the pack’s Column Format, any formula referring to that column uses the formatted value (the decimal) - not the underlying value (the integer). Is this by design or a bug? Is the only way to avoid this is to to have a separate column for display and for underlying value?

  2. How can make it right-aligned? Even when returning a Number data type, it still appears as left-aligned.

resultType: coda.ValueType.Number,
schema: {
   type: coda.ValueType.Number,
   codaType: coda.ValueHintType.Currency,
   format: coda.CurrencyFormat.Financial,
},

It still appears like this

7.00
400.50
1000.00

Instead of the more convenient (as possible with normal Number formatting).

   7.00
 400.50
1000.00

Interesting idea. I don’t know the answer to your second question, but for the first: yes that behaviour is intentional. It becomes more obvious with packs that return complex things like objects (which display as chips you can hover on to see the sub-properties). Other columns can access the “formatted” version of the cell (ie the pack’s output) so that you can access sub-properties like weather.precipitation and weather.high.

1 Like

Thanks for that perspective @Nick_HE
I guess it does make sense, though from my perspective (albeit being a Coda noob), it would have made more sense for the value itself to be the formula, which returns the rich object that other formulas could use, and for the Column Format to only affect rendering.

I suppose then, the only approach is to have separate columns - one for the raw value to be used in calculations, and the other - purely for rendering.

@Dan_Guberman,

this is not expected behaviour i.m.h.o.

you are returning a number type, so it should be right justified.

you are seeing the behaviour of a text column. which is not correct.

so i suspect it is a bug. somehow your number/hint=currency is converting into a text.

meantime, you can force right justification using X.RightPad(N,’ ') … but you need to know the column width, N, beforehand, which may be an issue.

@Agile_Dynamics, ok, good to know that I wasn’t doing anything outright wrong.
Do you know if Coda has a good process to submit bugs?

yes, click the question-mark icon at the bottom-left of any coda page and you can send messages to coda support. as part of the dialog you will be asked for the type of issue, thats where you indicate its a bug you are reporting

max