Setting a value in real time.

161 views
Skip to first unread message

Ray

unread,
Aug 23, 2023, 2:08:21 PM8/23/23
to redcap open
I have a form with single choice radio buttons with choices like so

1, ONE
2, TWO
3, THREE

I want a text box value to be set IN REAL TIME to the TEXT value of the choice (ONE, TWO, THREE)

I need to do this for an excel export report.  All the fields in the report EXCEPT this one are exported as numeric values as per the required spec but this particular value in the report must be text.  So when a choice is selected I need the text value to populate the field in real time.

What happens with the setvalue tag is I have to re open the form before export in order for the value to be set.  If I do not do this there is missing data (blank field) in the export report.  Doesn't seem like a big deal but it is when  dealing with a large recordset.

Calculated fields only work with numeric fields I have found so can't do it that way.

Any help appreciated.


Jeff Theobald

unread,
Aug 23, 2023, 4:43:18 PM8/23/23
to redcap open
Hi,
Have you considered the @CALCTEXT action tag? : 
"Evaluates logic that is provided inside a @CALCTEXT() function and outputs the result as text, typically performed with an if(x,y,z) function - e.g., @CALCTEXT(if([gender]='1', 'male', 'female')). NOTE: It is important to realize that a field with @CALCTEXT will not be editable on the survey page or data entry form, and the field will function almost exactly like a normal calculated field, in which its value may get updated via a data import, when running Data Quality rule H, or in real-time during normal data entry on a form or survey. ..."

Not sure if this syntax is exactly right, but I'm thinking you could use nested IFs within the @CALCTEXT action tag, like this: 
@CALCTEXT(if([variable]='1', 'ONE', if([variable]='2', 'TWO', if([variable]='3', 'THREE', ''))))

Use that action tag in a text field, and I think it will update in real time, on the form.
Hope this helps,
Jeff

Luke Stevens

unread,
Aug 23, 2023, 5:47:00 PM8/23/23
to Ray, redcap open

Hello Ray,

 

You could use a text field with the @CALCTEXT action tag and a nested if() expression:

 

@CALCTEXT(

  if([radfld]='1','ONE',

  if([radfld]='2','TWO',

  if([radfld]='3','THREE',

  '')))

)

 

The simplest way, however, might be to just set up your choice field with text values instead of numbers:

 

ONE, ONE

TWO, TWO

THREE, THREE

 

I hope that helps.
Luke

Luke Stevens
Research Data Systems Manager
Clinical Epidemiology & Biostatistics Unit (CEBU)
Murdoch Children's Research Institute
The Royal Children's Hospital, 50 Flemington Road
Parkville, Victoria 3052 Australia
T   +61 3 9345 6552
E   luke.s...@mcri.edu.au
W  mcri.edu.au

 

 

From: redca...@googlegroups.com <redca...@googlegroups.com> On Behalf Of Ray
Sent: Thursday, August 24, 2023 4:08 AM
To: redcap open <redca...@googlegroups.com>
Subject: [EXTERNAL]Setting a value in real time.

 

CAUTION:  External Email. Please be cautious with attachments and clicking links

 

--
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/07606d01-98e6-424d-82c9-81e8895496f5n%40googlegroups.com.



This e-mail and any attachments to it (the "Communication") are, unless otherwise stated, confidential, may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of Murdoch Children’s Research Institute (MCRI) ABN 21 006 566 972 or any of its related entities. MCRI does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

Reply all
Reply to author
Forward
0 new messages