Notion Answers

Help between Notion users


Register & Ask

It's free & easy

Get answers

Answers, votes & comments

Vote and select answers

Receive points, vote and give the solution

Question

1vote

How to add background color and style into ifs formula

Hello,

I tried creating the following formula to create a background based on whether wOBA is greater or less than a certain amount. However, there is no output when I try to do this. If I do >=0.400, style ("purple_background") instead of just >0.400, style ("purple_background"), there is an output, but it is just the text "purple_background" with a red background and doesn't change based on the value of wOBA. How do I fix this?

ifs(prop("wOBA")>0.400, style("purple_background", prop("wOBA")<0.400, style("blue_background"), prop("wOBA")<0.370, style("green_background"), prop("wOBA")<0.340, style("gray_background"), prop("wOBA")<0.320, style("yellow_background"), prop("wOBA")<0.310, style("orange_background"), prop("wOBA")<0.300, style("pink_background"), prop("wOBA")<0.290, style("red_background")))

1 Answer

0vote

polle Points97850

You are using the style as the result and you need an actual result before styling it.

This is how it works.

if(prop("wOBA") > 0.400, " Result ".style("purple_background"), "")

Just change the " Result " for what you actually want to output in each one of them.

But you will run into problems because of the numbers and the order of them, keep in mind it is progressive, so you can't just add them with no structure and order.

Try to use this instead.

if(prop("wOBA") > 1 and prop("wOBA") < 4, " Result ".style("purple_background"), "")

Then repeat with as many as you need. That way is specific and with no errors.

Hope that helps.

1vote

PsychologyVan commented

Great, thanks, that was really helpful!

I had to rework it a little bit but this is what I ended up using with success:

ifs(
  (prop("wOBA") *  100) >= 40, "Excellent".style("b","orange_background"),
  (prop("wOBA") * 100) < 40 and (prop("wOBA") * 100) >= 37, "Great".style("b","green_background"),
  (prop("wOBA") * 100) < 37 and (prop("wOBA") * 100) >= 34, "Above Average".style("b","blue_background"),
    (prop("wOBA") * 100) < 34 and (prop("wOBA") * 100) >= 32, "Average".style("b","purple_background"),
  (prop("wOBA") * 100) < 32 and (prop("wOBA") * 100) >= 31, "Below Average".style("b","red_background"),
  (prop("wOBA") * 100) < 31 and (prop("wOBA") * 100) >= 30, "Poor".style("b","brown_background"),
  (prop("wOBA") * 100) < 30, "Awful".style("b","gray_background")
)

0vote

polle commented

Glad it worked. Please consider selecting the answer to mark the question as solved.

Please log in or register to answer this question.

...

Welcome to Notion Answers, where you can ask questions and receive answers from other members of the community.

Please share to grow the Notion Community!

Connect