Knowledge: Using repeater in calculated field to total several rows
Back
Knowledge
Title*Using repeater in calculated field to total several rows
ManualAdministration
Manual Level TwoData Rooms
Manual Level ThreeForms Design
Created24/06/2020
DetailThis example shows how to add numbers together from within a repeater.
OnSave Formula
Below is the formula you need. XmlField1 should be the underlying database field for your repeater.
cast(XmlField1 as xml).value('sum(!Xpath!)', 'float')
Add a repeater xpath (use !Xpath! to insert in to formula)
In the below we are targeting NumberField1 as the underlying field for values you want to total. Please replace with your required number field database value.
//RepeaterData/Repeat/*[@DatabaseValue="NumberField1"]/@Value
Adding extra conditions
If you need to restrict the totalled rows to ones where another field in the repeat is set to a specific value, the following format can be used:
//RepeaterData/Repeat[Data/@DatabaseValue="TextField1" and Data/@Value="example"]/Data[@DatabaseValue="NumberField1"]/@Value
Additional Manual Locations