Forum Discussion

DerickDavis's avatar
DerickDavis
Qrew Trainee
7 years ago

Case Function Syntax Error

Can someone help me to identify the syntax error in the following Case function?

Case([calc Days Until Promise Dt],
    <Days(0),"Overdue",
    <=Days(2),"Due in 2 Days",
    <=Days(4),"Due in 4 Days"
    <=Days(7),"Due in 7 Days",
    >Days(7),"Beyond 7 Days"
)

//Where[calc Days Until Promise Dt] is of type formula Duration

2 Replies

  • I did notice the missing comma, but I'm still getting the same syntax error.   I've also tried the following without success:

    Case([calc Days Until Promise Dt],
        <0,"Overdue",
        <=2,"Due in 2 Days",
        <=4,"Due in 4 Days",
        <=7,"Due in 7 Days",
        >7,"Beyond 7 Days"
    )
    //Where[calc Days Until Promise Dt] is of type formula Duration
  • This is an old post that no-one had answered, but I was having a similar issue and so thought I'd post my solution in case anyone else comes across this.

    It seems that Case function can't handle inequalities, seems to only do a simple match i.e. in Case(X,Y,Z), it only checks if X=Y. However, found a work-around in the Sample Formulas public app: https://login.quickbase.com/db/bcgahn76w?a=q&qid=-5636905&dr=1

    To summarize, in my Case(X,Y,Z) example, you can use "true" or "false" as X and simply put the full inequality statement as Y and then Case will compare the "true" or "false" in X against the result of the inequality.  Example from the Sample Formulas App:

    Case(true, [percent complete]=0,"not started", [percent complete]<1,"in process", [percent complete]=1,"complete","")



    ------------------------------
    Anthony Guillen
    ------------------------------