Constrain Total Value of Repeat Entries

1675
7
Jump to solution
07-22-2022 12:44 PM
AndrewShuman2
New Contributor II

I have a survey that is trying to track work hours done on a variety of tasks. Each different task is set on a repeat. Each worker must account for 8 hours in a day. 

 

Is it possible to sum the value of the entries and constrain it so that the sum of the entries must be over 8?

 

This is how I have it set up now:

 

typenamelabelcalculationconstraintconstraint message
calculatetotal_hoursTotal Hours${hours_admin}+...{hours_yardwaste}${total_hours}>=8Must Enter 8 Hours

 

What am I missing? I have attached my xlsx.

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

I changed the field to a note and it all worked.  It will not fire on constraint on the field that is just a calculate since it does not show on the screen.

DougBrowning_0-1659024367912.png

As you see above though I do not think this is what you want as this requires each task to be 8.  You need a total outside the repeat and a constraint on that. And you need to bind to decimal otherwise 123 thinks its a string.  (or use decimal then hidden appearance) See attached.

But in the end why are you making one hours field for each type?  This form could be way, way simpler just having a hours field.  See second attached.  You repeat table will show which task it was.  Going forward your original schema is going to be a nightmare to use.  Basically you have to check all those fields all the time.  Just use one hours field is the better schema way to do it.

Hope that helps

 

 

View solution in original post

0 Kudos
7 Replies
AndrewShuman2
New Contributor II

I don't know if my xlsx attached before. 

0 Kudos
DougBrowning
MVP Esteemed Contributor

Probably because some entries are blank.  A blank gets '' which cannot be added since it is not a number.

Usually use coalesce for this  coalesce(${hours_yard_waste_collection}, 0)  this way it is is empty it gets a 0 instead.

Hope that helps

AndrewShuman2
New Contributor II

Do I need to apply that individually to each answer in the Calculation, or in total as I've shown in the updated xlsx?

0 Kudos
DougBrowning
MVP Esteemed Contributor

Nope have to do it for each one.  Copy paste and it should not be too bad.  Always good to test in a temp field to make sure before doing it all.

0 Kudos
AndrewShuman1
New Contributor

Sorry, replying back with a work account now. I guess I'm not clear where I am supposed to be adding the Coalesce function. Is it each individual Calculation field? Is it Total Hours Calculation field. I've tried both and I am not having success. Adding in the Coalesce to the total_hours Calculation field is the only place where I have gotten Connect to accept it.

 

I've attached the sheet for reference.

0 Kudos
DougBrowning
MVP Esteemed Contributor

I changed the field to a note and it all worked.  It will not fire on constraint on the field that is just a calculate since it does not show on the screen.

DougBrowning_0-1659024367912.png

As you see above though I do not think this is what you want as this requires each task to be 8.  You need a total outside the repeat and a constraint on that. And you need to bind to decimal otherwise 123 thinks its a string.  (or use decimal then hidden appearance) See attached.

But in the end why are you making one hours field for each type?  This form could be way, way simpler just having a hours field.  See second attached.  You repeat table will show which task it was.  Going forward your original schema is going to be a nightmare to use.  Basically you have to check all those fields all the time.  Just use one hours field is the better schema way to do it.

Hope that helps

 

 

0 Kudos
AndrewShuman1
New Contributor

Perfect! That works great! Thank you.

0 Kudos