Toggle navigation
Home
▼ Details
Products and pricing
Chart gallery
User stories
Text analytics
CDC NAMCS Library
Blog
Tutorials
Contact
Sign in
Post Editor
← All help posts
View post
Save
<img src="/uploads/upload/image/5200/direct/1595435286742-1595435286742.png" alt="Conceptual diagram showing a ratio calculation with two survey questions labeled Q1 and Q2. The diagram displays two browser window icons with question labels connected by a diagonal division line, illustrating the concept of dividing one question by another to create a ratio." style="width: 492px;" class="fr-fic fr-dib"> Let's say your survey asked for quantities in absolute counts. But now you want the option to report them as percentages. This tutorial demonstrates how you can do just that, and correctly preserve percentages, frequencies and averages. # Example Here, we have two questions: - **S8**: How many patients do you treat for Condition X? - **Q2**: How many of those patients do you treat with the following therapies? <img src="/uploads/upload/image/5200/direct/1587642280803-1587642280803.png" alt="Protobi data view showing question S8 with the text 'How many of the Condition X patients do you manage are on a GA (gamma antagonist)?' The view displays a horizontal bar chart showing patient count ranges from 1-10 up to 141-150, with percentages for each range. The highest percentage is 27.0% for the 11-20 range." style="text-align: center; width: 393px;" class="fr-fic fr-dib"> <img src="/uploads/upload/image/5200/direct/1587643202336-1587643202336.png" alt="Protobi data view showing question Q2 asking about therapy usage. The display is set to 'Compact to Mean' and shows seven therapy products (Product A through G plus Other) with their mean values and blue horizontal bars. Values range from 0.745 (Other) to 12.6 (Product A)." style="text-align: center; width: 405px;" class="fr-fic fr-dib"> To create a new group that displays **percentages** of respondents' patients being treated with each different therapy we need to calculate a ratio (Q2\_x / S8). ## Clone the group (optional) You might want to clone **Q2** to create a new group for the ratio values (see [Move, mirror, clone](/editaccess/copy "Go to tutorial") tutorial.) You don't *have* to clone the element unless you want to see both the original counts and the ratio. In this example, we've opted to clone **Q2** and name the new group **Q2vS8**. It's necessary to use a recursive clone because we want to clone the parent group, but also create independent copies of its children. ## Set denominator For the new group, press the square edit icon and choose "More properties..." from the context menu. Then, next to "denominator" enter "S8". <img src="/uploads/upload/image/5200/direct/1587651526652-1587651526652.png" alt="Element properties dialog showing configuration for question Q2vS8. The dialog displays various fields including key, displayKey, title, and type. Two fields are highlighted with red borders: 'scale' set to 100, and 'denominator' set to S8, demonstrating the key settings for creating ratio calculations." style="text-align: center; width: 360px;" class="fr-fic fr-dib"> ## Scale the percentages to 100 In the same properties dialog, set the "scale" to 100. As an analyst you may be familiar seeing percentages in the interval of 0 to 1. But your client may prefer to see ratio on an interval of 0 to 100. ## Result Voilá! After setting denominator, and using a scale of 100, we now have a new group that is defined as Q2\_x / S8. <img src="/uploads/upload/image/5200/direct/1587649791467-1587649791467.png" alt="Protobi data view showing the calculated ratio results for question Q2vS8. The display shows therapy percentages after dividing Q2 values by S8 and scaling to 100. Each product (A through G plus Other) now displays multiple percentage ranges with horizontal bars, showing the distribution of percentage values across respondents." style="text-align: center;" class="fr-fic fr-dib"> # Additional options ## Select custom value bins Press the square edit icon and choose "[Round by...](/edit-access/bin-numeric-values)" to create custom rounding for the group. For a question measured in percentage, we recommend rounding by 20. <img src="/upload/image/5200/direct/1587649297597-1587649297597.png" style="text-align: center; width: 295px;" class="fr-fic fr-dib"> ## Zero-fill \[NA\] values If some respondents were counted as \[NA\], and you want those values to count as 0 you can showMissing and recode \[NA\]s to "0". 1\. Choose "More properties..." from the context menu. Then, next to "showMissing" choose "Yes". <img src="/uploads/upload/image/5200/direct/1587649396485-1587649396485.png" alt="Close-up of element properties showing the showMissing dropdown menu expanded with three options: Yes (selected and highlighted in blue), No, and (default). This setting controls whether missing values are displayed in the data view." style="text-align: center; width: 428px;" class="fr-fic fr-dib"> 2\. Choose "Recode..." from the context menu. Drag \[NA\] over to the "(New code)" button and name it "0". <img src="/uploads/upload/image/5200/direct/1587644416171-1587644416171.png" alt="Recode dialog showing the interface for recoding missing values to zero. The left side shows 'Codes' with a blue '(New code)' button and a box containing '0' as the new code value with '[NA]' listed below it. The right side shows 'Uncoded values' with '(uncoded)' and a count of 0." style="text-align: center;" class="fr-fic fr-dib"> ## Limit the question to a subset of respondents If you want to consider only a certain subset of respondents for the question, create a [permanent filter](/edit-access/element-filters) on the group. In the example below, we want to limit the responses in **Q2vS8** to respondents who indicated they are a "Practice Nurse" in **S1**. First, press "Practice Nurse" in **S1** to create a filter. <img src="/uploads/upload/image/5200/direct/1587649861595-1587649861595.png" alt="Side-by-side view of two questions: Q2vS8 showing therapy percentages compacted to mean, and S1 showing specialty selection. In S1, 'Practice Nurse' is highlighted with a yellow bar showing 100.0% and appears selected with an orange arrow indicator, while 'General Practitioner' shows 0.0%." style="text-align: center; width: 710px;" class="fr-fic fr-dib"> Then, choose "Filters..." from **Q2vS8** context menu and apply the current filters. <img src="/uploads/upload/image/5200/direct/1587644791328-1587644791328.png" alt="Filters dialog showing options for applying filters to an element. The dialog displays two radio button options: 'Clear filters' and 'Apply current filters to this element' (which is selected). Below is explanatory text about using filters for skip patterns." style="text-align: center; width: 310px;" class="fr-fic fr-dib"> The element is now permanently limited to Practice nurses, and this is automatically labeled in the footnote. <img src="/uploads/upload/image/5200/direct/1587649934993-1587649934993.png" alt="Protobi data view of Q2vS8 after applying permanent filter, showing therapy percentages compacted to mean for Practice Nurses only. Seven products are listed with their percentage values and blue bars. At the bottom, a red-outlined footnote reads 'S1 is 'Practice Nurse*', automatically documenting the applied filter."" style="text-align: center;" class="fr-fic fr-dib"> ## Edit footnotes [Footnotes](/edit-access/titles-display-key-and-footnotes) can be edited directly by pressing on the existing footnote text. You can also edit footnotes in "More properties..." from the context menu. Next to "footnote" enter your text. <img src="/uploads/upload/image/5200/direct/1587652086653-1587652086653.png" alt="Close-up of element properties showing the footnote field with a text input box containing 'Among all Practice Nurses'. This demonstrates how to manually edit or customize footnote text for an element." style="text-align: center; width: 405px;" class="fr-fic fr-dib"> ## Scale bars using maxValue If you prefer not to [scale percentages to 100](http://help.protobi.com/advancededitor/ratios#Scale%20the%20percentages%20to%20100-3), then you might want to scale the bars. By default bars are scaled to 100, but if the percentages are being displayed in the interval of 0 to 1, the default setting won't be ideal. Set "maxValue" under "More properties..." to reference a value by which to scale bars for the element or group. This is useful when compacting to **mean**, so that bars can be drawn for means relative to some value. <img src="/uploads/upload/image/5200/direct/1594897924037-1594897924037.png" alt="Close-up of element properties showing the maxValue field with a text input box containing the value '1'. This setting controls the scale used for drawing horizontal bars when displaying mean values." class="fr-fic fr-dib"> **Q3** compacted to mean, without maxValue: <img src="=/uploads/upload/image/5200/direct/1594898340831-1594898340830.png" alt="Protobi data view of question Q3 compacted to mean without maxValue set. Shows seven therapy products with very small decimal values (ranging from 0.0170 to 0.289) and correspondingly very short blue horizontal bars that are barely visible, demonstrating the problem when percentages are on 0-1 scale but bars default to 0-100 scale." style="width: 370px;" class="fr-fic fr-dib"> After maxValue is set to 1: <img src="/uploads/upload/image/5200/direct/1594897946508-1594897946508.png" alt="Protobi data view of question Q3 compacted to mean after maxValue is set to 1. Shows the same seven therapy products with the same decimal values (0.289 to 0.0170), but now with appropriately scaled blue horizontal bars that are clearly visible and proportional to the values, demonstrating the solution to the bar scaling problem." style="width: 383px;" class="fr-fic fr-dib"> ## Calculate ratio averages By default, when you use the "denominator" property, the mean is intelligently weighted to show the ratio average, (i.e., the sum of numerators over sum of denominators, excluding rows with missing values for either). ## Calculate simple ratios If you want to calculate a simple ratio, Protobi's default calculation method can be turned off. To calculate average of ratios-- as in, calculate Q2\_x/Q8 for each respondent, and then average the resulting ratios, you can turn ratioMean off be using the attribute in JSON: ``` "ratioMean":false ``` ## **Q2vS8** turning "ratioMean" off: <img src="/uploads/upload/image/5200/direct/1587654180680-1587654180680.png" alt="Protobi data view of Q2vS8 with ratioMean turned off, showing compacted mean values for seven therapy products. The values and bar lengths differ from the default ratio calculation, demonstrating how disabling ratioMean changes from weighted ratio average (sum of numerators / sum of denominators) to simple average of individual ratios." style="text-align: center; width: 393px;" class="fr-fic fr-dib"> ## Video tutorial [Calculate ratios](/videos/calculate-ratios-video)
Publishing
Date
Status
Published
Draft
Slug
edit
Content
Thumbnail
Categories
Manage
New to Protobi?
Charts
Making Changes
Intermediate topics for editors
Frequently Asked Questions
SERMO Topics
Tutorial Pages
Internal Docs
Data Processing
Videos
Obsolete
GSG Admin
SERMO Admin
GSG Topics
How to...
Basics for viewers
Basics for editors
For project admins
Advanced topics
Assessments
Articles (in-progress)
New and updated articles
Process data in Protobi
superseded
Text open-end questions
Troubleshooting
Tracking studies
Organizing the view
API References
Tools
AI Database
Checking AI...
Convert to MD
Danger zone
Delete