# How to combine If() formulas?

Hi,

I have one column where you select a score out of 10 using a select list, and want the action column to auto assign the priority based on this using the If() condition formula. I put in the below formula which works:

If(thisRow.[Score (1/10)]=[1]ORthisRow.[Score (1/10)]=[2]ORthisRow.[Score (1/10)]=[3],[Urgent priority],[Low priority])

I have added a screenshot of the formula that works. This means that is the score is 1, 2 or 3 then the priority column automatically becomes ‘urgent priority’.

However I want to add another formula for if the score is 4, 5, 6, or 7 it is medium and then 8, 9 or 10 is low.

I cannot figure out how to have three IF() formulas in one formula that works together.

Hoping that this all makes sense and any help is really appreciated!

Here’s what I would recommend:

`if(Score<=3, "High priority", if(Score>=8, "low Priority", "medium Priority"))`

If score is less than or equal to 3, set High Priority, but if it’s greater than or equal to 8, set Low Priority. If it’s neither of those, then set “Medium Priority.”

I would also use a Slider for the Score column.

I put together a demo doc for you that shows how to do this.

1 Like

Hi Shannon,

Welcome to the community!

@Troy_Larson Troy gave you a good solution.

But because this is Coda, there are always many ways to climb the mountain…

Here is a comparison of a few:

1 Like

I think nesting if() formulas is bad practice. You really should use Switch() or Switchif(), they are easier to read, easier to edit for future changes, etc.

``````switchif(
thisRow.value<=3,"high",
thisRow.value<=8,"medium",
thisRow.value>8,"low",
"out of range"
)
``````
4 Likes

Amazing thank you so much for all of your replies, I got it working exactly as I need!

These type of questions come up frequently. The next question is often how you can sort your table if the values are text values that don’t sort properly when sorting on that column (like a table with sizes like Small, Medium Large, X-Large: that would sort
Large
Medium
Small
X-Large
By properly working with ‘lookup’ tables and using rank(), you can make solve a lot of these everyday problems.
You have to play with Coda Code quite a bit to see all the possibilities and it is kind of hard to explain, so I made a small sample (with some documentation) to show (rather than just tell).
I hope it gets some of you, new users, on your way to enjoy the endless possibilities. Sometimes it seem like an overkill to do things the long way, but in the end, you will be rewarded with docs that keep working, even if conditions change.

3 Likes

This is brilliant! I didn’t even think of the sorting issue but actually would have been an issue for me so this has solved it, thank you for even making the dash it’s very useful and I’ll be giving it a go today!

Yes, `switchif` is a much cleaner solution!