how do I force a number field to format as a ratio?

• 0
• Question
• Updated 2 years ago
• In Progress
I have a number field that I would like to format as a ratio when the user enters data (e.g. 5:1).
Is there a way to do this in Quickbase?
• 280 Points

Posted 2 years ago

• 0

Ⲇanom the ultimate (Dan Diebolt), Champion

• 30,224 Points
See this:

Number To Fraction ~ Add New Record
https://haversineconsulting.quickbase.com/db/bm6bhiqar?a=nwr

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=607

Text Formula with some HTML allowed:
`"<img src onerror='this.outerHTML=( function(x) { var tolerance = 1.0E-6; var h1=1; var h2=0; var k1=0; var k2=1; var b = x; do { var a = Math.floor(b); var aux = h1; h1 = a*h1+h2; h2 = aux; aux = k1; k1 = a*k1+k2; k2 = aux; b = 1/(b-a); } while (Math.abs(x-h1/k1) &gt; x*tolerance); return h1+&quot;/&quot;+k1; } )(" & [Number] & ")'>"`

Notes:

(1) Continued Fraction expansion algorithm:

http://jonisalonen.com/2012/converting-decimal-numbers-to-ratios/

(2) In the formula you could easily convert the "/" to ":" to produce a ratio.

(3) This solution uses the  OEH Technique - the OError HTML Technique named of course after the "Ooo - eeeee - hoo!" chant sung by the Winkie Guards in the Wizard of Oz (that is what they are singing  - it is in the script if you don't believe me):

https://community.quickbase.com/quickbase/topics/are-there-any-new-pre-service-worker-disruptive-tec...

(Edited)