Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Making decimal numbers fractions
megabri
<p>Does anyone know if BIRT has a way of making decimal numbers into fractions. An example would be if I had 56.75 I'd want to show 56 3/4. Thanks!</p>
Find more posts tagged with
Comments
kclark
<p>I haven't used it but it looks like there is a JS lib that you could include in your report to do this, maybe in a computed column? <a data-ipb='nomediaparse' href='
https://github.com/ekg/fraction.js'>Take
a look at it here</a></p>
megabri
<p>I'll give that a try. I've never included a library into a report before. How do I do it?</p>
kclark
<p>You should be able to add it as a resource in the resources tab from the property editor then call it like normal. You could also point to it <a data-ipb='nomediaparse' href='
http://www.eclipse.org/birt/phoenix/project/notable4.3.php#jump_6'>using
head.js.</a></p>
megabri
<p>I tried the library and tried using the following line in my fetch</p><p> </p><p>row["ststswitchthrmeasure"] = new Fraction(maximoDataSet.getDouble("ststswitchthrmeasure"));</p><p> </p><p>When it printed out it printed as [object Object]. Any ideas how to make it work? Thanks!</p>
kclark
<p>Try using this, I found it online over the weekend and it works well in a text item.</p><pre class="_prettyXprint _lang-"><script>function highestCommonFactor(a,b) { if (b==0) return a; return highestCommonFactor(b,a%b);}var decimal = "13.42";var decimalArray = decimal.split(".");var leftDecimalPart = decimalArray[0];var rightDecimalPart = decimalArray[1];var numerator = leftDecimalPart + rightDecimalPartvar denominator = Math.pow(10,rightDecimalPart.length);var factor = highestCommonFactor(numerator, denominator);denominator /= factor;numerator /= factor;document.getElementById("solution").innerText = numerator + "/" + denominator;</script><div id="solution"></div></pre>
GLO_FR
<p>Hi,</p><p> </p><p>I made a very basic report using computed columns</p><p>It calculated the decimal part in fraction.</p><p> </p><p>Hope it helps</p><p> </p><p> </p>