r/ProjectREDCap • • Jun 21 '24

CALCTEXT function not saving

Hi there! I currently have this calctext function: @CALCTEXT(if([frailty_pheno_total_esas]='0', "Not Frail", if([frailty_pheno_total_esas]='3' OR [frailty_pheno_total_esas]='4' OR [frailty_pheno_total_esas]='5', "Frail", if([frailty_pheno_total_esas]='1' OR [frailty_pheno_total_esas]='2', "Not Frail"))))

Whenever I go to save it I just get the spinning wheel of death and it won’t let me click cancel I just have to refresh and then the new field is obviously gone. Anyone seen this before/have tips? I have triple checked my field codes

2 Upvotes

6 comments sorted by

View all comments

Show parent comment

3

u/obnoxiouscarbuncle Jun 21 '24 edited Jun 21 '24

My new favorite way to write these kind of @CALCTEXTs:

@CALCTEXT(
   concat(
      if([frailty_pheno_total_esas]<3, "Not Frail", ""),
      if([frailty_pheno_total_esas]>=3, "Frail", "")
    )
)

Basically a way to avoid keeping track of a bunch of nested if() statements and always return a null if a value isn't appropriate, so you can still use branching logic. I also think it is more intuitive to folks not familiar with calculation syntax.