Answered

How to color a formula based on an IF statement

I have added a formula inside one of my Word templates. Based on the user's selection inside the screen-form, on the PDF version it will appear 'Pass,' 'Fail,' or a blank space.

I'm using green for Pass, and red for Fail. I have tried to use the green and red colors to the formula {{(IF(NOTBLANK({{PassorFail}}), IF({{PassorFail}} = 'Pass', 'Pass', 'Fail'), ''))}}, but no matter what parts of it I color I always get one or the other.  Both statements become green or red, but not 'Pass' and 'Fail.'

Does anyone know how I can achieve this effect?

Thanks so much.

  • Gabriela, you might try using UNICODE instead, such as a green checkmark or a red X. 

    {{(IF({{PassFail}} = ‘Fail’, ‘\u2716’, ‘\u2714’))}}

    Or you could do something like this, where the formulas are right next to each other:

    {{(IF({{PassFail}} = ‘Fail’, ‘Fail’, ‘’))}} {{(IF({{PassFail}} = ‘Pass’, ‘Pass’, ‘’))}}

    Let us know how those work and which one you choose! 

  • Victor, thank you for your suggestions. I have tried the formulas and variations of it, and unfortunately, none seem to work. They all show a blank space.

    I know that this formula {{(IF(NOTBLANK({{PassorFail}}), IF({{PassorFail}} = 'Pass', 'Pass', 'Fail'), ''))}} works great. It displays Pass, Fail or a Blank Space depending on the users' choice. However, I can't seem to find any options to change the text color of the answers accordingly—green for Pass, and red for Fail.  


    Thank you!

  • Gabriela,

    I have not had the time to test things. Have you tried using the UNICODE? That I know works.

    Victor

  • I perfectly understand. Thank you for all the help you have given me. I've tried some variations of 'Pass' '\2714' & 'Fail' '\274C', but I haven't been lucky.

    It works when I use this formula {{(IF({{PassorFail}}='Pass', ‘Pass’, ‘’))}} {{(IF(NOT({{PassorFail}}='Pass'), ‘Fail’,’’))}}. However, it doesn't have a blank space option. So near, yet so far.

  • Hi Gabriela,

    We would suggest using a table with HIDEIF statements, all formatted with your desired color, in order to properly show the Pass/Fail results from the form on the output with your desired colors. Something like this below will work well, showing green Passes, red Fails, and nothing for any other result (like N/A):

    image

    The table borders can be hidden if desired.

    ~Support


    1 person likes this
  •  

    Thank you for your excellent solution. This is exactly what I needed.  

Login or Signup to post a comment