multiple If statements in @CALCTEXT

4,585 views
Skip to first unread message

Rosanne Pogash

unread,
Sep 19, 2021, 6:43:31 PM9/19/21
to redcap open
Can you use multiple "if statements" using the action tag @CALCTEXt?

I have a situation where there are two variables. If either of the variables is checked "Yes", I want the field to display "Positive".... if not "Negative." 
@CALCTEXT(if([var1]="1" or [var2]="1"), "Positive", "Negative")

However, I want the field to stay missing if neither of the variables have a response entered.  When the user opens up the form, the new variable will display "Negative" prior to entering a value for [var1] or [var2].  I don't want anything to display and be saved as such in the database.

I could use branching logic to only display the @CALCTEXT field if the two variables are not missing.  However, when the use opens up the form, the user receives a message about setting the field to missing (since the field already is defined as "Negative").  This is confusing for novice REDCap research staff and could lead to errors in the database.

I would appreciate any syntax that would solve this problem.

Thanks,

Rosanne

SAMUEL OSAGIE

unread,
Sep 19, 2021, 10:22:08 PM9/19/21
to Rosanne Pogash, redcap open
Dear Rossanne,

I have a similar issue, the use of branching brought up a pop-up window where the field already has a value, I have to manually clear and close the window. It will be great to get a pointer.

_____
Thank you for your usual cooperation & be assured of my warmest regards now and always.

Osagie Samuel E  
BSc (Port Harcourt), MSc(Ilorin), MCPN
HEAD, 
WEB DESIGN & DEVELOPMENT (WDD)
&
Chief System Analyst & Cloud Infrastructure Architect
ITMS
University of Abuja, 
FCT - Abuja
Nigeria.
&

Aviatrix Certified Engineer - Multi-Cloud Network Associate(ACE)

Mikrotik Certified Network Associate (MTCNA)
Mikrotik Certified User Management(MTCUME)
Huawei Certified ICT Associate (HCIA-Artificial Intelligence)
Huawei Certified Academy Instructor (HCAI)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"You are what you repeatedly do. Excellence is not an event - it is a habit. -- Aristotle"
"beware of the lollipop of mediocrity lick it once you will suck forever"

NOTICE & DISCLAIMER: This email and any files transmitted with it may contain confidential or copyright materials and are for the attention of the addressee only. If you have received this email in error please notify us by email reply and delete it from your system. The University of Abuja accepts no liability for any damage caused by any virus transmitted by this email.


--
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/bad6e2cb-84b6-420e-a25b-9915fb9fec76n%40googlegroups.com.

David Edwards

unread,
Sep 19, 2021, 11:43:06 PM9/19/21
to Rosanne Pogash, redcap open
Hi Roseanne,

If I've understood this scenario correctly, part of the problem here is using checkboxes for [var1] and [var2]. The calculation has no way of differentiating between the fields not being completed yet and the fields being deliberately not ticked by the user. So all you can do is assume it's "Negative" from the outset, which is not necessarily the case, hence the problem.

So instead , you could change [var1] and [var2] to yes/no fields, and use this:

@CALCTEXT(if(([var1]<>'' and [var2]<>''), if(([var1]='1' or [var2]='1'), 'Positive', 'Negative'),''))

I hope this helps.

All the best.
David.





From: redca...@googlegroups.com <redca...@googlegroups.com> on behalf of Rosanne Pogash <rmpo...@gmail.com>
Sent: 19 September 2021 22:43
To: redcap open <redca...@googlegroups.com>
Subject: multiple If statements in @CALCTEXT
 
Reply all
Reply to author
Forward
0 new messages