{"id":4778,"date":"2026-04-09T09:30:33","date_gmt":"2026-04-09T13:30:33","guid":{"rendered":"https:\/\/health.uconn.edu\/clinical-research-center\/?page_id=4778"},"modified":"2026-04-09T17:05:53","modified_gmt":"2026-04-09T21:05:53","slug":"redcap-logic-hub","status":"publish","type":"page","link":"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/guides-how-tos\/redcap-logic-hub\/","title":{"rendered":"REDCap Logic Hub"},"content":{"rendered":"<div class=\"in-page-tabs\"><ul id=\"menu-redcap\" class=\"menu nav nav-tabs\"><li id=\"menu-item-4436\" class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children dropdown\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">REDCap Usage<b class=\"caret\"><\/b><\/a>\n<ul class=\"dropdown-menu\">\n\t<li id=\"menu-item-4437\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/uch-redcap-user-agreement\/\">REDCap User Agreement<\/a><\/li>\t<li id=\"menu-item-4439\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-project-eligibility\/\">REDCap Usage &amp; Project Eligibility<\/a><\/li>\t<li id=\"menu-item-4440\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-user-eligibility\/\">REDCap User Eligibility<\/a><\/li>\t<li id=\"menu-item-4438\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/new-redcap-policy-and-fee-faq\/\">REDCap Usage Fees<\/a><\/li><!--.dropdown-->\n<\/ul>\n<\/li><li id=\"menu-item-4441\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-account-request\/\">REDCap Account Request<\/a><\/li><li id=\"menu-item-4446\" class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children dropdown\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/redcap-login-issues\/\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">REDCap Login Issues<b class=\"caret\"><\/b><\/a>\n<ul class=\"dropdown-menu\">\n\t<li id=\"menu-item-4447\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-account-request\/uchc-user-login-issues\/\">UCHC User Login Issues<\/a><\/li>\t<li id=\"menu-item-4448\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-account-request\/login-issues\/\">UConn &amp; External Users Login Issues<\/a><\/li><!--.dropdown-->\n<\/ul>\n<\/li><li id=\"menu-item-4442\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-training\/\">REDCap Training<\/a><\/li><li id=\"menu-item-4443\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/guides-how-tos\/\">REDCap Guides &amp; How-to<\/a><\/li><li id=\"menu-item-4449\" class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children dropdown\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/scheduled-maintenance\/\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">REDCap Maintenance<b class=\"caret\"><\/b><\/a>\n<ul class=\"dropdown-menu\">\n\t<li id=\"menu-item-4678\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/scheduled-maintenance\/\">REDCap Maintenance<\/a><\/li>\t<li id=\"menu-item-4450\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/scheduled-maintenance\/new-features-improvements\/\">REDCap Upgrade Details<\/a><\/li><!--.dropdown-->\n<\/ul>\n<\/li><li id=\"menu-item-4451\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-systems\/\">REDCap Systems<\/a><\/li><li id=\"menu-item-4452\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/using-redcap-for-nih-data-sharing\/\">Using REDCap for NIH Data Sharing<\/a><\/li><li id=\"menu-item-4453\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/citing-redcap\/\">Citing REDCap<\/a><\/li><li id=\"menu-item-4455\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap_news\/\">REDCap News You Can Use<\/a><\/li><\/ul><\/div><h1 id=\"top\" class=\"redcap-logic-hub\" style=\"max-width: 1100px;margin: 0px auto;line-height: 1.7;color: #1f2937;text-align: center\"><strong>Branching Logic, Calculations, Syntax, Testing, and Troubleshooting:<br \/>\nA Clear Guide to How Logic Works Across Your REDCap Project<\/strong><\/h1>\n<div><\/div>\n<div class=\"redcap-logic-hub\" style=\"max-width: 1100px;margin: 0px auto;line-height: 1.7;color: #1f2937\">\n<p>&nbsp;<\/p>\n<p>Logic is one of the most powerful features in REDCap. It controls when fields appear, how values are calculated, how reports are filtered, when notifications are triggered, and how workflows behave across classic, longitudinal, and repeating projects. This page provides a centralized guide to the core logic concepts used throughout REDCap.<\/p>\n<p>This guide is designed to help you make sense of branching logic, calculated fields, and the core logic patterns used throughout REDCap. Whether you are building a new project or troubleshooting an existing one, this page provides a practical framework for understanding how logic works and how to use it effectively.<\/p>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 14px 16px;margin: 22px 0;border-radius: 4px\"><strong>Core Principle:<\/strong> In REDCap, logic always evaluates to <strong>true<\/strong> or <strong>false<\/strong>. The key is to build logic that is clear, testable, and appropriate for the field type and project structure.<\/div>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 14px 16px;margin: 22px 0;border-radius: 4px\"><strong>Important:<\/strong> The same general logic language is used across many REDCap features, but the behavior may differ depending on where the logic is used. Branching logic, calculated fields, ASIs, Alerts, Survey Queue, reports, and dashboards all use related syntax, but not always in exactly the same way.<\/div>\n<div style=\"background: #f0f9ff;border: 1px solid #bae6fd;padding: 16px 18px;margin: 24px 0;border-radius: 6px\">\n<h2 style=\"margin-top: 0;font-size: 1.2em\">On this page<\/h2>\n<ul style=\"margin: 0;padding-left: 20px\">\n<li><a href=\"#where\">Where Logic Is Used in REDCap<\/a><\/li>\n<li><a href=\"#building-blocks\">Logic Building Blocks<\/a><\/li>\n<li><a href=\"#branching\">Branching Logic<\/a><\/li>\n<li><a href=\"#calculations\">Calculated Fields<\/a><\/li>\n<li><a href=\"#dates\">Working with Dates and Time<\/a><\/li>\n<li><a href=\"#longitudinal\">Longitudinal, Repeating, and Smart Variables<\/a><\/li>\n<li><a href=\"#action-tags\">Logic and Action Tags<\/a><\/li>\n<li><a href=\"#testing\">Testing and Troubleshooting<\/a><\/li>\n<li><a href=\"#updating\">Updating Calculation Values<\/a><\/li>\n<li><a href=\"#best-practices\">Key Best Practices<\/a><\/li>\n<li><a href=\"#deep-dive\">Take a Deeper Dive<\/a><\/li>\n<\/ul>\n<\/div>\n<h2 id=\"where\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Where Logic Is Used in REDCap<\/h2>\n<p>Logic is used across multiple parts of REDCap, not just branching logic and calculations. It can be used in:<\/p>\n<ul style=\"padding-left: 20px\">\n<li>Branching logic<\/li>\n<li>Calculated fields<\/li>\n<li>Automated Survey Invitations<\/li>\n<li>Alerts &amp; Notifications<\/li>\n<li>Survey Queue<\/li>\n<li>Data Quality rules<\/li>\n<li>Report filters<\/li>\n<li>Project dashboards<\/li>\n<\/ul>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Simple rule:<\/strong> Before writing logic, make sure you know <strong>where<\/strong> the logic will be used, because that affects how the logic behaves and what features are compatible.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"building-blocks\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Logic Building Blocks<\/h2>\n<p>Most REDCap logic uses the same core syntax elements:<\/p>\n<ul style=\"padding-left: 20px\">\n<li><strong>Variables<\/strong>: <code>[variable_name]<\/code><\/li>\n<li><strong>Operators<\/strong>: <code>=<\/code>, <code>&lt;&gt;<\/code>, <code>&gt;<\/code>, <code>&lt;<\/code>, <code>&gt;=<\/code>, <code>&lt;=<\/code><\/li>\n<li><strong>Boolean logic<\/strong>: <code>and<\/code>, <code>or<\/code><\/li>\n<li><strong>Parentheses<\/strong>: used to group statements<\/li>\n<\/ul>\n<h3>Strings vs Numbers<\/h3>\n<p>Use quotes when comparing strings or coded values that should be treated as strings. Leave quotes off for true numeric comparisons.<\/p>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>[gender] = '1'<\/code><br \/>\n<code>[weight] &gt; 100<\/code><br \/>\n<code>[last_name] &lt;&gt; \"\"<\/code><\/div>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> Use the <code>\"\"<\/code> pattern with no spaces when checking for blank or null values. A space inside the quotes changes the meaning.<\/div>\n<h3>Combining Statements<\/h3>\n<p>Use parentheses to control grouping and make complex logic easier to read.<\/p>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>([variable1] = '1' or [variable2] = '1') and [variable3] = '2'<\/code><\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"branching\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Branching Logic<\/h2>\n<p>Branching logic hides or shows a field based on conditions. In REDCap, the logic is placed on the <strong>destination field<\/strong> \u2014 the field you want to show or hide \u2014 not on the source field.<\/p>\n<h3>What Branching Logic Can Do<\/h3>\n<ul style=\"padding-left: 20px\">\n<li>Show a field only if a prior answer meets certain criteria<\/li>\n<li>Hide irrelevant questions<\/li>\n<li>Create cleaner, more dynamic instruments<\/li>\n<\/ul>\n<h3>What It Cannot Do<\/h3>\n<ul style=\"padding-left: 20px\">\n<li>It cannot skip or hide an entire instrument<\/li>\n<li>It cannot be applied at the section level<\/li>\n<li>It must be applied field by field<\/li>\n<\/ul>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> Section headers are hidden only when <strong>all<\/strong> fields in that section are hidden. Entire instruments remain visible even if every field on the form is hidden by branching logic.<\/div>\n<h3>Checkbox Logic<\/h3>\n<p>Checkbox fields use different syntax because each answer choice behaves like its own yes\/no field.<\/p>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>[race(2)] = '1'<\/code> \u00a0 checked<br \/>\n<code>[race(4)] = '0'<\/code> \u00a0 unchecked<\/div>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Design Tip:<\/strong> For more complex branching logic, it can help to build the basic statement with the drag-and-drop builder and then refine it manually using advanced syntax.<\/div>\n<\/div>\n<div id=\"top\" class=\"redcap-logic-hub\" style=\"max-width: 1100px;margin: 0 auto;line-height: 1.7;color: #1f2937\">\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"calculations\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Calculated Fields<\/h2>\n<p>Calculated fields perform real-time numeric calculations on forms and surveys. They use variable names in brackets and mathematical functions similar to Excel.<\/p>\n<h3>Core Rules<\/h3>\n<ul style=\"padding-left: 20px\">\n<li>Calculated fields can return <strong>numbers only<\/strong><\/li>\n<li>They cannot directly return text or dates<\/li>\n<li>Use mathematical order of operations carefully<\/li>\n<\/ul>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>[bpi_q1] + [bpi_q2]<\/code><br \/>\n<code>sum([q1],[q2],[q3],[q4])<\/code><br \/>\n<code>if([weight] &gt; 100, 44, 11)<\/code><\/div>\n<h3>Use <code>sum()<\/code> vs <code>+<\/code> Carefully<\/h3>\n<ul style=\"padding-left: 20px\">\n<li><code>sum()<\/code> ignores blank values<\/li>\n<li><code>+<\/code> requires all fields to have values<\/li>\n<\/ul>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> Which one to use depends on how the instrument should be scored. A missing value may need to be ignored or may need to invalidate the total.<\/div>\n<h3>Checkbox Calculations<\/h3>\n<p>Checkbox calculations are more complex because each answer choice is scored as checked or unchecked rather than by its visible choice code.<\/p>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>if([exercise(1)] = 1, 1, 0)<\/code><\/div>\n<div style=\"background: #fef2f2;border-left: 6px solid #dc2626;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> If possible, avoid using complex calculations on checkbox fields unless the scoring structure is very clear.<\/div>\n<h3>Special Functions<\/h3>\n<p>REDCap supports many functions in calculated fields, including:<\/p>\n<ul style=\"padding-left: 20px\">\n<li><code>round()<\/code>, <code>roundup()<\/code>, <code>rounddown()<\/code><\/li>\n<li><code>sqrt()<\/code>, <code>abs()<\/code><\/li>\n<li><code>min()<\/code>, <code>max()<\/code>, <code>mean()<\/code>, <code>median()<\/code>, <code>sum()<\/code>, <code>stdev()<\/code><\/li>\n<\/ul>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"dates\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Working with Dates and Time<\/h2>\n<p>Dates are commonly used in both branching logic and calculations. The most common function is <code>datediff()<\/code>.<\/p>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>datediff([dob],[visit_date],\"y\",\"mdy\")<\/code><br \/>\n<code>datediff(\"today\",[screen_date],\"M\")<\/code><\/div>\n<h3>Common Units<\/h3>\n<ul style=\"padding-left: 20px\">\n<li><code>\"y\"<\/code> years<\/li>\n<li><code>\"M\"<\/code> months<\/li>\n<li><code>\"d\"<\/code> days<\/li>\n<li><code>\"h\"<\/code> hours<\/li>\n<li><code>\"m\"<\/code> minutes<\/li>\n<li><code>\"s\"<\/code> seconds<\/li>\n<\/ul>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> Both dates must match the format you specify in the function. Test carefully whenever dates are part of logic or calculations.<\/div>\n<div style=\"background: #fef2f2;border-left: 6px solid #dc2626;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> While <code>\"today\"<\/code> can be used, it should be used carefully in calculated fields because the result changes whenever the form is re-opened and saved. A fixed project date field is often safer.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"longitudinal\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Longitudinal, Repeating, and Smart Variables<\/h2>\n<h3>Longitudinal Event References<\/h3>\n<p>In longitudinal projects, fields from other events must include the unique event name.<\/p>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>[baseline_arm_1][weight]<\/code><\/div>\n<h3>Repeating Instruments<\/h3>\n<p>You can reference a specific repeating instance by appending the instance number to the variable.<\/p>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>[variable1][4]<\/code><\/div>\n<h3>Smart Variables<\/h3>\n<p>Smart Variables make logic more flexible by referencing contextual concepts such as first event, previous event, or first instance.<\/p>\n<div style=\"background: #f9fafb;border: 1px solid #e5e7eb;padding: 14px 16px;border-radius: 6px;margin: 16px 0\"><code>[first-event-name][variable]<\/code><br \/>\n<code>[variable][first-instance]<\/code><\/div>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Design Tip:<\/strong> Event names and smart variables are powerful, but they add complexity quickly. Use them intentionally and test them thoroughly.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"action-tags\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Logic and Action Tags<\/h2>\n<p>Logic can interact with action tags, but action tags do not always behave like branching logic or calculations.<\/p>\n<h3>Important Interactions<\/h3>\n<ul style=\"padding-left: 20px\">\n<li><code>@HIDDEN<\/code> overrides branching logic and hides the field regardless of logic result<\/li>\n<li><code>@DEFAULT<\/code> works only if the field is shown when the form first loads<\/li>\n<li><code>@IF<\/code> allows conditional action-tag behavior<\/li>\n<li><code>@CALCDATE<\/code> and <code>@CALCTEXT<\/code> allow text\/date outputs that standard calculated fields cannot return<\/li>\n<\/ul>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> Action tags generally work when the form first loads and may not update in real time as data are entered.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"testing\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Testing and Troubleshooting<\/h2>\n<p>Logic should always be tested with real test records, not just by previewing a form.<\/p>\n<ul style=\"padding-left: 20px\">\n<li>Preview mode does <strong>not<\/strong> fully test branching logic or calculations<\/li>\n<li>Use realistic test records and enter data directly<\/li>\n<li>Use reports or Data Quality rules to validate complex logic<\/li>\n<li>Diagram complicated logic flows before building them<\/li>\n<\/ul>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Best Practice:<\/strong> For complex logic, draw out the logic in a flow chart before building it. This makes troubleshooting much easier.<\/div>\n<h3>Common Troubleshooting Points<\/h3>\n<ul style=\"padding-left: 20px\">\n<li>Wrong variable name or wrong event reference<\/li>\n<li>Using a checkbox field as if it were a radio field<\/li>\n<li>Blank value behavior not handled properly<\/li>\n<li>Calculated field hidden by branching logic but still returning data<\/li>\n<\/ul>\n<div style=\"background: #fef2f2;border-left: 6px solid #dc2626;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> If a calculated field is hidden by branching logic but still evaluates to a value, REDCap may show an error or warning. The fix is often to build the branching condition into the calculation itself using an <code>if()<\/code> statement that returns <code>\"\"<\/code> when hidden.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"updating\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Updating Calculation Values<\/h2>\n<p>When a calculated field is added or changed, the new calculation may appear on screen, but the values are <strong>not automatically saved<\/strong> to the server. This is why updated values may not appear in reports or exports right away.<\/p>\n<h3>How to Update Saved Values<\/h3>\n<ul style=\"padding-left: 20px\">\n<li>Go to <strong>Data Quality<\/strong><\/li>\n<li>Run <strong>Rule H<\/strong><\/li>\n<li>Review the listed fields and values<\/li>\n<li>Use <strong>Fix calcs now<\/strong> if appropriate<\/li>\n<\/ul>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Important:<\/strong> Rule H updates <strong>all<\/strong> listed calculation values unless you explicitly exclude specific items first. Review carefully before fixing values in bulk.<\/div>\n<div style=\"background: #f0fdf4;border-left: 6px solid #16a34a;padding: 12px 14px;margin: 16px 0;border-radius: 4px\"><strong>Best Practice:<\/strong> Run Rule H soon after adding or changing calculated fields so the list stays short and easier to review.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr style=\"margin: 30px 0;border: 0;border-top: 1px solid #d1d5db\" \/>\n<h2 id=\"best-practices\" style=\"background: #16a34a;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Key Best Practices<\/h2>\n<div style=\"background: #f0fdf4;border: 1px solid #16a34a;padding: 14px;border-radius: 6px\">\n<ul style=\"margin: 0;padding-left: 20px\">\n<li>Use clear variable names and consistent coding<\/li>\n<li>Keep logic as simple as possible<\/li>\n<li>Use parentheses intentionally in multi-part statements<\/li>\n<li>Know whether your field is a regular multiple-choice field or a checkbox field<\/li>\n<li>Test with realistic records and actual saved data<\/li>\n<li>Use event references and smart variables carefully in longitudinal or repeating projects<\/li>\n<li>Do not overuse calculated fields, especially on large forms<\/li>\n<li>Run Rule H after adding or changing calculations<\/li>\n<\/ul>\n<\/div>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 14px 16px;margin: 20px 0;border-radius: 4px\"><strong>Final Takeaway:<\/strong> Good logic should be readable, predictable, and easy to test. If the logic is difficult to explain, it is usually worth simplifying before putting it into production.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<\/div>\n<h2 id=\"deep-dive\" style=\"background: #329EB8;color: #ffffff;padding: 12px 16px;border-radius: 6px;margin-bottom: 16px\">Take a Deeper Dive<\/h2>\n<div><\/div>\n<div>\n<h3><strong><span style=\"color: #0000ff\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/guides-how-tos\/redcap-logic-hub\/redcap-branching-logic-a-practical-guide-to-dynamic-forms\/\" rel=\"\" style=\"color: #0000ff\">REDCap Branching Logic: A Practical Guide to Dynamic Forms<\/a><\/span><\/strong><\/h3>\n<h3><strong><span style=\"color: #0000ff\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/guides-how-tos\/redcap-logic-hub\/redcap-calculated-fields\/\" rel=\"\" style=\"color: #0000ff\">REDCap Calculated Fields: A Practical Guide to Scoring, Dates, and Dynamic Values<\/a><\/span><\/strong><\/h3>\n<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>REDCap Usage REDCap User Agreement REDCap Usage &amp; Project Eligibility REDCap User Eligibility REDCap Usage Fees REDCap Account RequestREDCap Login Issues UCHC User Login Issues UConn &amp; External Users Login Issues REDCap TrainingREDCap Guides &amp; How-toREDCap Maintenance REDCap Maintenance REDCap Upgrade Details REDCap SystemsUsing REDCap for NIH Data SharingCiting REDCapREDCap News You Can UseBranching Logic, [&hellip;]<\/p>\n","protected":false},"author":4679,"featured_media":0,"parent":2190,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"acf":[],"publishpress_future_action":{"enabled":false,"date":"2026-05-04 22:12:39","action":"change-status","newStatus":"draft","terms":[],"taxonomy":""},"_links":{"self":[{"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages\/4778"}],"collection":[{"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/users\/4679"}],"replies":[{"embeddable":true,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/comments?post=4778"}],"version-history":[{"count":12,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages\/4778\/revisions"}],"predecessor-version":[{"id":4816,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages\/4778\/revisions\/4816"}],"up":[{"embeddable":true,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages\/2190"}],"wp:attachment":[{"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/media?parent=4778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}