Forum Discussion
cathoms
Responsive Resident
5 years agoUsing "and" in a conditional column
I'm making a conditional column and instead of using the "Conditional Column" tool I thought I would try coding it in a custom colum. Is it possible to use "if-and" statements? My code throws up an error: Token Literal expected. Why am I getting this error and can I fix it?
= if [#"Days btw CNCL & APPT"] >= 92 then "More than 3 months"
else if [#"Days btw CNCL & APPT"] >= 61 and < 92 then "2-3 months"
else if [#"Days btw CNCL & APPT"] > 30 and < 61 then "1-2 months"
else if [#"Days btw CNCL & APPT"] > 14 and < 30 then "3-4 weeks"
else if [#"Days btw CNCL & APPT"] > 7 and < 14 then "1-2 weeks"
else if [#"Days btw CNCL & APPT"] > 2 and < 7 then "Within 1 week"
else if [#"Days btw CNCL & APPT"] <= 2 then "Within 48 hrs"
else if [#"Days btw CNCL & APPT"] <= 1 then "Within 24 hrs"
Thanks in advance!
= if [#"Days btw CNCL & APPT"] >= 92 then "More than 3 months" else if [#"Days btw CNCL & APPT"] >= 61 then "2-3 months" else if [#"Days btw CNCL & APPT"] > 30 then "1-2 months" else if [#"Days btw CNCL & APPT"] > 14 then "3-4 weeks" else if [#"Days btw CNCL & APPT"] > 7 then "1-2 weeks" else if [#"Days btw CNCL & APPT"] > 2 then "Within 1 week" else if [#"Days btw CNCL & APPT"] > 1 then "Within 48 hrs" else "Within 24 hrs"
2 Replies
- HotChilli
Community Champion
It needs an "else " case at the end
- CNENFRNL
Community Champion
= if [#"Days btw CNCL & APPT"] >= 92 then "More than 3 months" else if [#"Days btw CNCL & APPT"] >= 61 then "2-3 months" else if [#"Days btw CNCL & APPT"] > 30 then "1-2 months" else if [#"Days btw CNCL & APPT"] > 14 then "3-4 weeks" else if [#"Days btw CNCL & APPT"] > 7 then "1-2 weeks" else if [#"Days btw CNCL & APPT"] > 2 then "Within 1 week" else if [#"Days btw CNCL & APPT"] > 1 then "Within 48 hrs" else "Within 24 hrs"