Forum Discussion

cmaly's avatar
cmaly
Brass Contributor
Jul 01, 2020
Solved

Conditional formula to hide/show columns in Sharepoint List Edit Form

Hi,

I was able to create a formula based on this posting from Microsoft (link below) and it works great.  However, I want to be able to write it so it looks at 2 different values in a field to show the column or not in the Edit Form.  Can someone help me write the formula so that I can have an OR.....like in the example below I would like to have it work if "Category" equals Product OR Service.  

 

=if([$Category]=='Product','true', 'false')

 

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/list-form-conditional-show-hide

 

I did see someone say that this could be used as the indicator for or || but I wrote the formula lots of ways and never could get it to work.  Thank you.

  • Hi,
    Try this, it should work like a charm

    =if([$Category] == 'Product' || [$Category] == 'Service','true','false')
  • Sudharsan K's avatar
    Sudharsan K
    Steel Contributor
    Hi,
    Try this, it should work like a charm

    =if([$Category] == 'Product' || [$Category] == 'Service','true','false')
  • Sudharsan K's avatar
    Sudharsan K
    Steel Contributor
    Hi, have you tried using like the below

    =if([$Category]=='Product',=if([$Category]=='Service','true', 'false'), 'false')
    • LCarroll5554's avatar
      LCarroll5554
      Copper Contributor
      Hey is there a way to do this but for if you want both conditions to be true for it to show instead of just one, E.g. for when you are referencing 2 different columns and one is a number as seen below.

      =if([$Category]=='Product',=if([$Inventory]>='2','true', 'false'), 'false')

      If Category is ‘Product’ and Inventory is 2 or less

      • cmaly's avatar
        cmaly
        Brass Contributor

        Hi LCarroll5554 

         

        Try this

        =if([$Category]=='Product' && [$Inventory]>=2,'true', 'false')

         

Resources