Help! How can I create Multiple If statements to create a sum?

I’m trying to work out the following formula if a status says a specific word to multiply the time column by 100 then if it says something else times it by 200 etc. Heres the formula I’m trying to use but no sure where I’m going wrong!

IF(OR({Resource type}=“green”, SUM({Time tracking round up})*400)),IF(OR({Resource type}=“blue”, SUM({Time tracking round up})*200)))

@RuthQ

Case is important. But, assuming that your status labels are “green” and not “Green”, this should do what you want:

SWITCH({Resource type}, "green", {Time tracking round up} * 400, "blue", {Time tracking round up} * 200), 0)

Jim - The Monday Man (YouTube Channel)
Watch Our Latest Video: Column Total in monday.com Formulas? YES!!!
Check out our monday apps, now in beta: The Monday Man Apps

Hi Jim, Thanks for taking the time to help :slight_smile: :grinning:

I used the formula you suggested and it still came back with an illegal formula. I then removed the , 0) at the end and and this worked for the fields that were populated but the ones that weren’t still had an illegal formula. As there were a few more status’ to apply I thought just appending what you suggested and using “Other” would do the job. This works for two statuses but not if I want to apply more. Do you have any further suggestions? for example:

SWITCH({Resource type}, “green”, {Time tracking round up} * 400, “blue”, {Time tracking round up} * 200), “red”, {Time tracking round up} * 100) “Other”, {Time tracking round up} * 0)

Hey @RuthQ ,

imagine SWITCH as follow:

SWITCH( 
 Resource = {Resource type},
 Case1 = "green",
 Solution for Case1 = {Time tracking round up} * 400,
 Case2 = "blue",
 Solution for Case2 = {Time tracking round up} * 200),
 Case3 = "red",
 Solution for Case3 =  {Time tracking round up} * 100,
 Case4 = "Other",
 Solution for Case4 =  {Time tracking round up} * 0
)

As you can see you can just add more “cases” with their “solutions” to the SWITCH() function.
For example:

 Case5 = "yellow",
 Solution for Case5 =  {Time tracking round up} + 1000

and in terms of empty fields you could add a “solution” to an empty field like so:

Case6 = "",
Solution for Case6 = {Time tracking round up} * 0

So your switch would look like this:

SWITCH({Resource type}, "green", {Time tracking round up} * 400, "blue", {Time tracking round up} * 200, "", {Time tracking round up} * 0 )

Or use the default like @JCorrell mentioned (and is probably the better solution, because it covers everything which is not covered in your “cases”), which you can tell by the trailing 0 at the end:

SWITCH({Resource type}, "green", {Time tracking round up} * 400, "blue", {Time tracking round up} * 200, 0 )

You can always check how the formula fucntions work by hovering the functions in the configuration of the formula:

image

Hope I could help.

Greetings

@TMNXT-Dev @JCorrell Thanks for your help, I’ve got it working :grinning:

1 Like

@RuthQ

Sorry about that. I usually test stuff like this before posting… But, this one was “easy”… Oh well.

In my original answer, I missed deleting one of the “)” from your first formula (the one right after the “200”).

Here it is corrected:

SWITCH({Resource type}, "green", {Time tracking round up} * 400, "blue", {Time tracking round up} * 200, 0)

As written, it will return 0 when {Resource type} is neither “green” nor “blue”.

Jim - The Monday Man (YouTube Channel)
Watch Our Latest Video: Column Total in monday.com Formulas? YES!!!
Check out our monday apps, now in beta: The Monday Man Apps

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.