Show or Hide column based on condition in SharePoint Online list.

Featured image

Show or Hide column based on condition in SharePoint Online list

Microsoft announced an updated feature that is shown or hide the column in the SharePoint list based on a value in another column by specifying the conditional formulas, this formula is made with equations. In this blog, we can see how to create this conditional equation and the outcomes of this equation.

How to create a conditional formula?

  1. Go to SharePoint list → select the column which you want to set a conditional formula
  2. Select More options → select Edit → Edit form → Edit columns.

  1. specify the conditional formula based on other columns and click save.

Conditional formulas:

Now let’s consider the equation to perform the actions. The equation must start with = and followed with if condition, if the condition satisfies then it returns true this means it shows the column, else it returns false which makes the column to hide.

For example:

In our example, we are applying the formula in the column ‘workpercentage’. if the status value is completed then workpercentage need to be true, which means workpercentage needs to show up.
=if([$status]==’completed’,’true’, ‘false’)

Or else the workpercentage column will get hidden while editing.

Choice column:

This equation checks the choice column ‘status’ is equal to completed
=if([$status]==’completed’,’true’, ‘false’)

Number column:

This following formula check the number column ‘workpercentage’ is less than or equal to 50
=if([$workpercentage]<=120, ‘true’,’false’)

Arithmetic calculations

We can also do the arithmetic calculation such as adding the two column and checking its sum.
=if(([$Flightscost]+[$Hotelcost])>500, ‘true’,’false’)

Date column:

We can act with a date column(M/D/Y)
=if([$StartDate]==Date(‘5/21/2020’),’true’,’false’)
This data column can also play with operators (less than or equal to)
=if([$StartDate] >= Date(‘4/6/2020’),’true’,’false’) And we can also apply the condition for both start and enddate with the equation.
=if([$StartDate] >= Date(‘4/6/2020’) && [$EndDate] <= Date(‘6/10/2020’),’true’,’false’) For more sample formulas refer: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/list-form-conditional-show-hide#specify-conditional-formula-to-show-or-hide-columns

Unsupported column types:

Currently, they do not support the following column type

  1. Currency columns

  2. Location columns

  3. Calculated columns