Question

The below formula returns an error in SP online, how can I fix it?

if(
    AND(ISBLANK([Project start date]),equals([Cash flow distribution], 'Unknown')),true,
    if(
    AND(NOT(ISBLANK([Project start date])),not(equals([Cash flow distribution], 'Unknown')),true))
 )

I have tried simpler versions like the below ones:

  =if(AND(ISBLANK([Project start date])=TRUE,[Cash flow distribution]= 'Unknown'),TRUE,FALSE )
 

  = if(AND(ISBLANK([Project start date]),equals([Cash flow distribution], 'Unknown')),TRUE,FALSE )
 

  = if(AND(equals(ISBLANK([Project start date]),true),equals([Cash flow distribution], 
  'Unknown')),true,false )
 

  = if(AND(ISBLANK([Project start date])=TRUE,[Cash flow distribution]= 'Unknown'),"OK","NOT OK" )

 = if(AND(ISBLANK([Project start date])=TRUE,[Cash flow distribution]= 'Unknown'),TRUE,FALSE )

based on

How do I "validate" a column/field only if it's not blank

and

https://info.summit7systems.com/blog/part-2-how-to-conditionally-require-data-in-more-than-one-sharepoint-column

and

validating a column based on a value in another column

they should work,but they still return errors, I am writing this is the "Column Validation" of the [Cash flow distribution] column which is a multi-choice column (and not calculated).

Was it helpful?

Solution

For Column Validation errors are being thrown most likely due to the fact that referencing multiple columns in Column Validation is not allowed.

enter image description here

Instead if you go to List Settings > Validation Settings you can set a formula to validate the Item in the List which allows referencing multiple columns.

Using your original formula I have modified it to exclude the IF statement and instead use OR and AND to return TRUE as required.

=OR(AND(ISBLANK([Project start date]),[Cash flow distribution]="Unknown"),
AND(NOT(ISBLANK([Project start date])),[Cash flow distribution]<>"Unknown"))

Using the formula that you provided the following occurs:

  • You can have "Unknown" without a Date.
  • You cannot have other values without a Date.

Note though that you can have No Value with a Date, so not sure if that is acceptable?

enter image description here

OTHER TIPS

Don't use IF() in the validation formula. Use a formula that results in TRUE or FALSE, but not with IF().

You may want to test each component first before you plug them all together into one big formula. Are you certain that EQUALS() even is a valid function in this context? I've never come across this before. SharePoint formula syntax for this scenario is identical to Excel formula syntax, so comparisons can be done with = and <>.

Try something along these lines:

=or(
    AND(ISBLANK([Project start date]),[Cash flow distribution]="Unknown"),
    AND(NOT(ISBLANK([Project start date])),[Cash flow distribution]<>"Unknown")
 )

If it does not work, run tests with the individual components before putting together the complete formula, so you can troubleshoot which component is the problem in the configuration.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top