Skip to Main Content

IR

DescrValuePercRow NumPerc DiffPerc CountPerc Fixed
x-120-b12037.23-.1237.2
x-120-a12037.22-.1137.1
x-606018.61-.1318.6
x-23237.14-.147.1
Sum : 100.1Sum : 100

Info

Method to round percentages in such a way that the total is always 100%.

In this example, the percentages (rounded to 1 decimal) are computed using ratio_to_report (colum Perc). The total of these is 100.1, which is mathematically correct, but of course not what we'd like to see.
The difference between 100.1 and the (ideal) 100 (column Perc Diff) is added to the row with the highest value (120).

In this example there are 2 rows with this highest value, so we have to force a winner.
For this I used rownum, because that allows the Descr column of rows to be identical without causing problems. A side effect is that the sorting can be a bit odd; in this case it causes the "x-120-b" row to be the winner that the difference is added to (and therefore the top row after sorting), which may not be what you want. If the Descr column is always a unique value in your case, you can change the "perc_count" line in "a" to this:

Code

Region

Identification
Sequence
Title
Type
Source
Source Type
Region Source