Count of selected checkboxes

236 views
Skip to first unread message

Ray

unread,
Oct 25, 2023, 5:49:33 PM10/25/23
to redcap open
I have a checkbox for every day of the month so checkboxes numbered 1 through 30.

I understand that checked returns "1" and unchecked returns "0"

I need a calculated field to say on each record form how many checkboxes have been checked.  I could do it after the fact in excel by just summing the range where this element is listed but I need a single field on my form .. something like "days used = {how many have been checked}

I have seen a doc that says basically to create another set of 31 days to evaluate each checkbox and return either a 1 or a 0 and then sum these fields but that seems like a lot of work.  Hoping for something simpler.

Thanks in advance.

Any ideas?

Thanks in advance.

David Edwards

unread,
Oct 25, 2023, 6:25:49 PM10/25/23
to Ray, redcap open
Hi Ray,

I've not tried this so it's nothing more than a half baked idea, but .... how about just one calculated field that sums the result of whether each checkbox is checked?

The label would read something like "Number of ticked boxes: " and the calculation would look something like this...

      sum([chk_1(1):checked], [chk_1(1):checked], [chk_1(1):checked], ... ... ... [chk_30(1):checked])


Good luck, 
David.

From: redca...@googlegroups.com <redca...@googlegroups.com> on behalf of Ray <ray0...@gmail.com>
Sent: 25 October 2023 21:49
To: redcap open <redca...@googlegroups.com>
Subject: Count of selected checkboxes
 
--
You received this message because you are subscribed to the Google Groups "redcap open" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redcap_open...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redcap_open/1212c49c-eb4f-4c91-b2d8-f669fbf502f7n%40googlegroups.com.

Brad Trumpower

unread,
Oct 27, 2023, 10:45:27 AM10/27/23
to redcap open
You could also do it like this in a calculated variable: 
[check_box(1)] + [check_box(2)] + [check_box(3)] + [check_box(4)]

This assumes your value for each day is 1 and the label is 1-31. i.e., 
1,1
1,2
1,3
...
1,31

Reply all
Reply to author
Forward
0 new messages