SurveyLoopr
Tips & Tricks
12 min read

Fix the XLSForm Dependency Cycle Error (ODK, Kobo)

Mehrab Ali
Mehrab AliPublished November 16, 2026

The error "Dependency cycles amongst the xpath expressions in relevant/calculate" means a row depends on itself, and the fix is to remove that row's own name from its logic: write selected(${pests}, '-96') on the pests_other row, not selected(${pests_other}, '-96'). Newer versions of ODK Validate word the same error as "Cycle detected in form's relevant and calculation logic!". Every fixed example below compiles with pyxform and ODK Validate, the check ODK Central and KoboToolbox run on upload.

Download example form (.xlsx)All six fixed examples in one XLSForm, one group each. Tested with pyxform and ODK Validate; free to reuse under CC BY 4.0.Download

What does the dependency cycle error mean?

A form works out its answers in order: a calculation needs its inputs first, and a question needs its relevant condition settled before it can be shown. A cycle is a loop in that order. Row A needs row B, and row B needs row A, so neither can go first. The shortest loop is one row that needs itself.

You will see one of two wordings, depending on how old the validator is:

ODK Validate Errors:
>> Something broke the parser. See above for a hint.
Dependency cycles amongst the xpath expressions in relevant/calculate
Result: Invalid
ODK Validate Errors:
>> XForm is invalid.
: Cycle detected in form's relevant and calculation logic!
The following nodes are likely involved in the loop:
${pests_other}
Result: Invalid

They are the same error. The newer one is more useful because it names the rows involved.

How do I find the row that causes the cycle?

Start from the names in the message, then search the survey sheet.

  1. One name listed. That row refers to itself. Open it and look for its own name inside ${...} in the relevant, calculation or required column. If the name belongs to a group, a question inside the group is used in the group's own relevant.
  2. Several names listed. The rows form a chain. Follow it: the first row's logic mentions the second, the second mentions the third, and the last one points back to the first.
  3. No names listed (old wording). Search each logic column for rows that mention their own name first. That is the cause in most forum threads about this error. If you find none, check your most recent calculate rows for pairs that mention each other.

Only relevant, calculation and required take part. A question's own name in its constraint does not cause a cycle.

Note:

The cycle is checked on the form's logic, not on what an enumerator types. A loop that could "never happen in practice" is still rejected, so the form has to be rewritten; there is no setting that turns the check off.

Why does my "Other, specify" question cause a cycle?

Because the relevant was copied onto the specify row with the specify row's own name in it. The question says "show me only if I contain -96", which depends on itself. Point it at the select question above it:

typenamelabelrelevant
select_multiple pestspestsWhich crop pests did you see this season?
textpests_otherPlease specify the other pestselected(${pests}, '-96')
surveychoicessettings
list_namenamelabel
pests1Fall armyworm
pests2Stem borer
pests3Locusts
pests-96Other (specify)
surveychoicessettings

The broken version has selected(${pests_other}, '-96') in the same cell. The names differ by a suffix, which is why it survives a quick read. The full pattern, including select_one, is in "Other, please specify" in XLSForm.

How do I fix a calculation that refers to itself?

Give the calculation only inputs, never its own name. The usual case is a running total written the way a programmer would write it: ${total_exp} + ${health_exp} in the total_exp row. A calculate cannot add to its previous value. List every part instead:

typenamelabelcalculation
integerfood_expHow much did the household spend on food last week?
integerhealth_expHow much did the household spend on health last week?
integerschool_expHow much did the household spend on schooling last week?
calculatetotal_expcoalesce(${food_exp}, 0) + coalesce(${health_exp}, 0) + coalesce(${school_exp}, 0)
noteshow_totalTotal spending last week: ${total_exp}
surveychoicessettings

coalesce(${x}, 0) treats a skipped question as 0, so one empty answer does not blank the whole total. More patterns are in the XLSForm calculations guide.

How do I fix two calculations that depend on each other?

Rewrite one of them from the answers the enumerator types. Here the broken form had net_sales as ${sales} - ${fee} and fee as ${net_sales} * 0.1. Each needs the other. The market fee is really 10% of sales, so work it out from sales:

typenamelabelcalculation
integersalesWhat were the trader's total sales yesterday?
calculatefeeround(${sales} * 0.1, 0)
calculatenet_sales${sales} - ${fee}
noteshow_netSales after the market fee: ${net_sales}
surveychoicessettings

Longer chains work the same way. A relevant counts too: if question A is shown only when calculate C equals 1, and C is worked out from A, that is a loop even though only one of the rows is a calculate. Draw the chain on paper, find the arrow that points backwards, and replace that one reference.

Why does a group's relevant cause a cycle?

Because a group's relevant applies to every question inside it. If the gate question sits inside the group, it can only be asked when it has already been answered. The error names the group, not the question. Move the gate above begin group:

typenamelabelrelevant
select_one yes_nohas_childrenAre there children under 5 in the household?
begin groupchild_sectionChildren under 5${has_children} = '1'
integern_childrenHow many children under 5?
select_one yes_noany_sickWas any of them sick in the last 2 weeks?
end groupchild_section
surveychoicessettings
list_namenamelabel
yes_no1Yes
yes_no0No
surveychoicessettings

The same rule holds for a repeat with a relevant. See skip logic in XLSForm for group-level conditions.

How do I keep a running total in a repeat without a cycle?

Read the typed question from the earlier instance, and put the total outside the repeat. What fails is a calculate that reads its own value from the previous instance, such as indexed-repeat(${running}, ${delivery}, position(..) - 1) + ${bags} in the running row. The validator treats running as depending on running.

typenamelabelcalculationrelevant
begin repeatdeliveryDelivery
integerbagsHow many bags were delivered?
calculateprev_bagsindexed-repeat(${bags}, ${delivery}, position(..) - 1)
noteshow_prevThe delivery before this one had ${prev_bags} bags.position(..) > 1
end repeatdelivery
calculatetotal_bagssum(${bags})
noteshow_bagsTotal bags delivered: ${total_bags}
surveychoicessettings

prev_bags depends on bags, which is typed, so there is no loop. sum(${bags}) sits after end repeat, where it adds every instance. See sum values in a repeat group and indexed-repeat() for both functions.

Warning:

Do not move sum(${bags}) inside the repeat to get around the error. It compiles, but inside its own repeat ${bags} means the current instance only, so the "total" is just that one delivery.

Which columns can cause a cycle, and which cannot?

relevant, calculation and required can. constraint cannot, so both . >= 0 and ${age} >= 0 are accepted in the age row, although . is the normal way to write it. once() does not exempt a calculation either: once(if(${draw} = '', random(), ${draw})) is rejected, while once(random()) does the same job.

typenamelabelconstraintcalculation
integerageHow old is the respondent?. >= 0 and . <= 120
calculatedrawonce(random())
noteshow_drawRandom draw for this interview: ${draw}
surveychoicessettings

Common causes and the fix for each

Each broken version was run through ODK Validate; the last column is the name it printed under "likely involved in the loop".

Row and what you wroteWrite insteadName in the error
pests_other relevant: selected(${pests_other}, '-96')selected(${pests}, '-96')${pests_other}
total calculation: ${total} + ${amount}Add the inputs: ${amount} + ${other_amount}${total}
net = ${income} - ${tax} and tax = ${net} * 0.1tax = ${income} * 0.1${tax} and ${net}
Group g relevant: ${has_child} = '1', with has_child inside gMove has_child above begin group${g}
running calculation reads ${running} from the previous repeat instanceRead a typed question; sum() after end repeat${running}
nm required: ${nm} = ''yes${nm}
rand_id calculation: once(if(${rand_id} = '', random(), ${rand_id}))once(random())${rand_id}

For other upload messages, see common XLSForm errors, or paste the form into the free XLSForm validator.

Does this work the same in ODK, KoboToolbox and SurveyCTO?

The rule is the same everywhere: a form's logic may not loop. Where you meet the error differs.

PlatformWhere you meet it
ODK (pyxform, XLSForm Online, Central)On conversion or upload, as "ODK Validate Errors" with one of the two wordings above
KoboToolboxOn preview or deploy: "your form cannot be deployed because it contains errors", followed by the ODK Validate text
Older ODK CollectOn opening a blank form that was never validated, with the "Dependency cycles" wording
SurveyCTOSkip logic goes in a column named relevance. A row that refers to itself there is the same mistake, with the same fix

Why the validator is right to refuse the form

A loop has no correct answer. If a total includes itself, or a question is shown only when it is already answered, any value the app picked would be a guess. Refusing the form on upload costs a few minutes at the desk. A form that looped during an interview would cost the interview.

Tip:

Describe the rule in plain language instead: "ask for the other pest only when Other is ticked, and show total spending on food, health and school". LooprAI writes the rows and compiles the form with pyxform and ODK Validate before anything is saved, so a row that depends on itself never reaches your form.

Build my first form free

Next: common XLSForm errors →

Frequently Asked Questions

What does 'Dependency cycles amongst the xpath expressions in relevant/calculate' mean?

A row in your form depends on itself, either directly or through other rows. The form cannot decide which value to work out first, so ODK Validate rejects it. Newer versions word it as 'Cycle detected in form's relevant and calculation logic' and list the rows involved.

How do I find which question causes the dependency cycle?

Read the names after 'The following nodes are likely involved in the loop'. One name means that row mentions itself in its relevant, calculation or required column. Several names mean a chain between those rows. With the older message, search for rows that contain their own name.

Why does my Other specify question give a dependency cycle error?

Its relevant tests its own name, usually after a copy and paste: selected(${pests_other}, '-96') on the pests_other row. Change it to test the select question above it, selected(${pests}, '-96'), so the text box depends on the list and not on itself.

Can a calculate refer to itself to keep a running total?

No. A calculation such as ${total} + ${amount} in the total row is a cycle, and wrapping it in once() does not help. Add the input questions directly, or inside a repeat use sum() on the typed question after the end repeat row.

Does using a question's own name in its constraint cause a cycle?

No. Constraints are not part of the cycle check, so ${age} >= 0 in the age row compiles, although a dot is the usual way to write it. The columns that can form a cycle are relevant, calculation and required.

Why does the cycle error name a group instead of a question?

The group's relevant uses a question that sits inside the same group. A group's condition applies to everything in it, so that question would decide whether it is asked. Move the question above the begin group row and the error goes away.

No Credit Card Required

Build the form first. Add hosting when you need it.

Start free with LooprAI, then deploy a managed ODK Central server or run DataSnap checks when your project is ready.

Automation handles the mechanical work.

Researchers decide what the evidence means.