Default answer based on two previously asked questions

314 views
Skip to first unread message

Michelle R

unread,
Sep 28, 2023, 5:01:39 AM9/28/23
to redcap open
If e.g. answer 1 is filled in question 1 (radio button) and answer 1 is filled in question 2 (radio button), then answer 4 should be selected automatically in question 3  (radio button) ... I had tried this with @IF and @DEFAULT action tags, but it just won't work. Is this function possible at all?

Roberto Ferreira

unread,
Sep 28, 2023, 10:12:38 AM9/28/23
to Michelle R, redcap open
Hi Michelle,

The rationale used is correct, but @IF does not work in real time as if it were a calculated field, you need to save the record to see how it works.

Em qui., 28 de set. de 2023 às 06:01, Michelle R <m.r...@gmail.com> escreveu:
If e.g. answer 1 is filled in question 1 (radio button) and answer 1 is filled in question 2 (radio button), then answer 4 should be selected automatically in question 3  (radio button) ... I had tried this with @IF and @DEFAULT action tags, but it just won't work. Is this function possible at all?

--
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/870ea4f3-8680-45c9-809f-82a67da173ffn%40googlegroups.com.

David Edwards

unread,
Sep 28, 2023, 1:34:17 PM9/28/23
to Michelle R, redcap open
Hi Michelle,

Unfortunately, the @DEFAULT action tag only kicks in the first time an instrument is loaded. @SETVALUE is a bit better in that it kicks in every time the page is loaded but it's still no good for what you need as it only kicks in on the page load, not when users change answers on the page.

So unless, anyone can think of another way of doing it with a radio button, then a potential workaround is to change Question 3 from a radio button to a text field, then use the @CALCTEXT action tag in that text field to work out the answer based on the answers to question 1 and 2. e.g.

      @CALCTEXT(IF([question_1]='1' and [question_2]='1',  4, X))

Where X is whatever answer you want to show if Question 1 or Question 2 are not answered with '1'.
You could have another IF() statement instead of X if there are more rules dictating the answers to question 3.

Best of luck,
David.

From: redca...@googlegroups.com <redca...@googlegroups.com> on behalf of Michelle R <m.r...@gmail.com>
Sent: 28 September 2023 09:01
To: redcap open <redca...@googlegroups.com>
Subject: Default answer based on two previously asked questions
 
If e.g. answer 1 is filled in question 1 (radio button) and answer 1 is filled in question 2 (radio button), then answer 4 should be selected automatically in question 3  (radio button) ... I had tried this with @IF and @DEFAULT action tags, but it just won't work. Is this function possible at all?

David Edwards

unread,
Sep 28, 2023, 1:47:35 PM9/28/23
to Michelle R, redcap open
Update:

I think the answer may need to be in quotes, so a slight correction:

@CALCTEXT(IF([question_1]='1' and [question_2]='1',  '4', 'X'))


From: redca...@googlegroups.com <redca...@googlegroups.com> on behalf of David Edwards <dw...@hotmail.com>
Sent: 28 September 2023 17:34
To: Michelle R <m.r...@gmail.com>; redcap open <redca...@googlegroups.com>
Subject: Re: Default answer based on two previously asked questions
 
Reply all
Reply to author
Forward
0 new messages