How to write Nested IF statements each on separate line?

Waseem K
Waseem K ✭✭
edited 12/09/19 in Smartsheet Basics

Hi, 

I have this nested IF statement that I would like to have each IF condition on a new line for easier reading and to follow coding best practices. 

Here is what I have now: 

=IF(COUNT(CHILDREN([Task Name]@row)) > 0, IF(COUNTIF(CHILDREN(), "Red") > 0, "Red", IF(COUNTIF(CHILDREN(), "Yellow") > 0, "Yellow", IF(COUNTIF(CHILDREN(), "Green") > 0, "Green", "Gray"))), IF([% Complete]@row = 1, "Gray", IF(Finish@row >= TODAY() + 7, "Green", IF(Finish@row >= TODAY() + 3, "Yellow", "Red"))))

 

I would like it to look like this: 

=IF(COUNT(CHILDREN([Task Name]@row)) > 0,

  IF(COUNTIF(CHILDREN(), "Red") > 0, "Red",

  IF(COUNTIF(CHILDREN(), "Yellow") > 0, "Yellow",

  IF(COUNTIF(CHILDREN(), "Green") > 0, "Green", "Gray"))),

  IF([% Complete]@row = 1, "Gray",

  IF(Finish@row >= TODAY() + 7, "Green", IF(Finish@row >= TODAY() + 3, "Yellow", "Red"))))

 

I would appreciate if anyone can guide me to the shortcut or a way to get this done, thanks!

Comments