I've created a repeating with a number of calculated values inside. There's one with a lookup function that works fine, others maths calculations that work fine, and then one with an If function that checks whether a tick box is set to true, if it is it takes its value from field A, if its not it takes its value from field B!
This last one does not work.
If I remove it from the repeating section it does work, but then the control doesn't function properly as it's not scoped to the row that it belongs to, so if I add a second row and select my tick box it will take override the first row and my calculations will be wrong.
calculations are correct in this image with 1 row
Now with a second row my calculations go all crazy.
If I move the calculated value inside the repeating section it simply fails to update when the tick box "Override Markup" is selected and the markup will stay the same. The calculations are correct, but the user no longer has the ability to set their own markups.
My formula is
The replace function is in there because the values were being returned in  suggesting that it was expecting an array, but it shouldn't have been. However, without the replace functions the issue still remains.
Any help really appreciated here.
Solved! Go to Solution.
Looking only at the images you have provided, it is difficult to tell exactly what you are attempting to achieve, but let me take a stab.
You mention a Field B, but never specify where it's located. Is it outside of the Repeating Section? Is the user setting a Form Wide Markup that should be applied whenever that box is checked?
I also must assume that a default markup value, per the Repeating Section Row, is set based off of some other *thing* like the Category.
Something like that is easily achievable:
I just used the formula below in the 'Total With Markup' Calculated Control:
If(Overide_Markup,(Cost*Qty) + ((Cost*Qty)*(Markup Override Value/100)),(Cost*Qty) + ((Cost*Qty)*(Markup/100)))
Because checkboxes are converted to boolean values, you don't need to write out 'Override_Markup == "true"'. Simply inserting the control as a reference will do the trick.
Is this about right?
Thanks. Although your mock up isn't exactly as I have (the New Markup value exists inside the repeating section and a different value can be applied to each row in the repeating section) simply removing the OverrideMarkup==true from my If statement got everything working.
It's odd as in theory
should both resolve the same way but clearly not in this case.
Thanks for the pointer. Problem solved.
if you used expression: OverrideMarkup==true
then it would work, since you would compare two boolean values
if you however used expression: OverrideMarkup=="true"
you compared boolean value to a string value. non empty string value is always treated as (boolean) true
I just spotted that in my formula.I honestly don't know why that is in there.
I know that it's a boolean, not string. I blame parenthood and sleep deprivation!