Instance Tables

22 views
Skip to first unread message

David Edwards

unread,
Mar 6, 2026, 6:16:55 AM (3 days ago) Mar 6
to redcap open
Hello all,

I have a question about Luke Stevens's brilliant Instance Table external module ...

I'm using it inside a Daily Treatment form, which (as you might expect) repeats daily for a given participant during the treatment phase of a trial.

Within each Daily Treatment form, there will be an instance table which can have up to a maximum of 3 rows added to it.

And for various reasons, I need to keep track of how many rows have been added per form, and per participant.

So is there a way to:

  1. Count how many rows have been added so far on a given Daily Treatment form?

  2. Count how many rows have been added so far on all Daily Treatment forms for a given participant?


Thank you,

David.

Page

unread,
Mar 6, 2026, 4:01:21 PM (3 days ago) Mar 6
to Redcap Open
The Instance Table functions within the Repeating Instrument format within REDCap. So everything related to instances of the repeating instrument can be used in this context. 
Option 1: A proxy for how many instances of your Daily Treatment form have been submitted could be to use the [last-instance] smart variable where if you have 3 instances [last-instance] would be 3. This does not count the instances per se, but just says 'what is the number assigned to the last instance?'. (Example: Perhaps 1,2,3,4 instances were entered and then #2 was deleted so you really only have 3 instances, but [last-instance] would give you 4)

Option 2:  If you actually want to count the instances, you can make a hidden helper field on your instrument that equals 1:
Open text field called [treatmentformcount] where @DEFAULT='1'.
Then build a calc like this: [aggregate-sum:treatmentformcount:record-name]
 to count the number of fields that exist which should tell you the true number of instances per record for the 

David Edwards

unread,
Mar 6, 2026, 4:35:50 PM (3 days ago) Mar 6
to Redcap Open, Page
Thank you very much for your help - I like option 2 so I'll make a note to try it next week.

Oh and ... before I finished work today, Chat GPT told me I could use [count:instrument_name] and [count:instrument_name][current-instance] to solve this problem.
After a long and bizarre conversation, including a wild goose chase looking for an external module that doesn't exist, Chat GPT admitted it had hallucinated the smart variable because it looked like something that could plausibly exist in REDCap.

Oh how we larfed.

Lessons learned!


From: 'Page' via Redcap Open <redca...@googlegroups.com>
Sent: 06 March 2026 21:01
To: Redcap Open <redca...@googlegroups.com>
Subject: [REDCap Open] Re: Instance Tables
 
--
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 visit https://groups.google.com/d/msgid/redcap_open/ec6d8967-5120-4e8a-85e2-aad9373f0c29n%40googlegroups.com.

Peter Macisaac

unread,
Mar 6, 2026, 5:52:36 PM (3 days ago) Mar 6
to David Edwards, redcap Open
Sounds like a good change request to put to REDCap central - perhaps AI is showing the ability to envisage something that plausibly might be based on a use case given -  a good example of what AI might help us achieve -  perhaps AI should be trained to refer to some of its hallucinations and imagination


Peter

David Edwards

unread,
Mar 6, 2026, 6:05:36 PM (3 days ago) Mar 6
to Peter Macisaac, redcap Open
Loving the positive spin there Peter 🙂

Unfortunately, the way I spoke to Chat GPT after that, I'll likely be one of the first up against the wall come the rise of the machines!


From: Peter Macisaac <pe...@macisaacinformatics.org>
Sent: 06 March 2026 22:52
To: David Edwards <dw...@hotmail.com>
Cc: redcap Open <redca...@googlegroups.com>
Subject: Re: [REDCap Open] Instance Tables
 
Reply all
Reply to author
Forward
0 new messages