Forum Discussion

tonyb1986's avatar
tonyb1986
Copper Contributor
Jul 27, 2022
Solved

Multiple IF statement

Hi all,

 

i am trying to create a calculated column in sharepoint online document library i was hoping to use the following if statement but i cant see where the issue is or why its not working, i have now spent over a day on this and not getting anywhere, any help will be much appreciated!

 

the if statement i am trying to use is:

=IF([Document Type]="Form","F-",

       IF([Document Type]="Document","D-",

          IF([Document Type]="SOP","SOP-")))

 

am i missing something very silly?

 

 

  • tonyb1986  

    It looks correct and works for me when I test with the same code. I have sometimes experienced that there can be problems with language settings so you can try replacing the " with ' and see if that helps.


    The statement You are trying to use (that does not work):

    =IF([Document Type]="Form","F-",

    IF([Document Type]="Document","D-",

    IF([Document Type]="SOP","SOP-")))


    The statement i am using (that works for me):

    =IF([Document Type]="Form","F-",IF([Document Type]="Document","D-",IF([Document Type]="SOP","SOP-")))


    A statement that might work for You:
    =IF([Document Type]='Form','F-',IF([Document Type]='Document','D-',IF([Document Type]='SOP','SOP-')))

     

    If that variant doesn't work, maybe you can try removing the line breaks in your code and typing/pasting the code the way I wrote it with everything on one line. (That shouldn't be the solution but you never know 🙂

     

3 Replies

  • tonyb1986 Syntax of IF function is like: 

     

    IF(condition, <true value>, <false value>)

     

    You are missing <false value> for last IF function in formula. So, try using this formula: 

     

    =IF([Document Type] = "Form", "F-", IF([Document Type] = "Document", "D-", IF([Document Type] = "SOP", "SOP-", "")))

     

    NoteSometimes comma ( , ) does not work in formula (I am not sure but it is based on something language or regional settings on your site). So in that case use semicolon ( ; ) instead of comma ( , ) like: 

     

    =IF([Document Type] = "Form"; "F-"; IF([Document Type] = "Document"; "D-"; IF([Document Type] = "SOP"; "SOP-"; "")))

     


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

  • tonyb1986  

    It looks correct and works for me when I test with the same code. I have sometimes experienced that there can be problems with language settings so you can try replacing the " with ' and see if that helps.


    The statement You are trying to use (that does not work):

    =IF([Document Type]="Form","F-",

    IF([Document Type]="Document","D-",

    IF([Document Type]="SOP","SOP-")))


    The statement i am using (that works for me):

    =IF([Document Type]="Form","F-",IF([Document Type]="Document","D-",IF([Document Type]="SOP","SOP-")))


    A statement that might work for You:
    =IF([Document Type]='Form','F-',IF([Document Type]='Document','D-',IF([Document Type]='SOP','SOP-')))

     

    If that variant doesn't work, maybe you can try removing the line breaks in your code and typing/pasting the code the way I wrote it with everything on one line. (That shouldn't be the solution but you never know 🙂

     

    • tonyb1986's avatar
      tonyb1986
      Copper Contributor
      thanks for this MagnusGoksoyrOLDProfile, i used the formula that you were using and worked for me also, however I cant see any difference between my formula and yours (I pasted these both in notepad to check) either way it works and I am happy so thank you for your help!

Resources