Show or Hide Columns in a SharePoint List Form

You can show or hide columns in a list or library form as an alternative to deleting them. When you hide a column, it doesn’t affect the column or the data in the column, as it would if you delete it. To re-use the column, you can simply show it again in the form.

To show or hide a column in a list form:

  1. Go to the list for which you want to show or hide columns in the form.
  2. Double click an item to open the form to view the item details.
  3. At the top of the form, select Edit form > Edit columns.
  4. In the Edit columns pane, check (to show) or uncheck (to hide) the checkbox for the column or columns as needed.
  5. When you’re finished, select Save.
Edit columns 1
Edit columns 1
Edit columns 2
Edit columns 2

đź’ˇNote

  • You cannot hide the required columns.

If you want to re-arrange the order of the columns, either drag-and-drop the column name or first select the far right-hand edge of the column name to display the options


Specify Conditional Formula to Show or Hide Columns

You can show or hide columns in a list form based on another column’s value by specifying a formula that are equations performing conditional checks on values in a SharePoint list or library.

To specify a conditional formula for a column, in the Edit columns pane:

  1. Navigate to the desired column for which you want to set a conditional formula
  2. Select the far right-hand edge of the column name to display the options menu (…)
  3. In the more options, select Edit conditional formula.
  4. In the Edit conditional formula dialog:
    • To determine whether this column is shown or hidden, specify a conditional formula based on the value of another column.
    • To clear the condition, leave it blank.
  5. When you are finished, select Save.
Edit columns in the form
Edit columns in the form
Edit conditional formular
Edit conditional formular
In this case, it means that the Material Number column will be shown if the formular is true (when adding new item to the list), otherwise it will be hidden (when the item has already been added to the list).

Conditional Formulas

Formulas are equations that perform conditional checks on column values in a list or library. A formula starts with an equal sign (=) followed by the if function that returns either a true or a false result.

Returning true shows the column on the form while returning false hides the column.

The column is represented by specifying the internal name of the field surrounded by square brackets and preceded by a dollar sign: [$InternalName]. For example, to get the value of a field with an internal name of “ProductName”, use [$ProductName].

1)       Unsupported column types in conditional formulas

While the formula supports many of the available column types, the following column types are not currently supported:

  • Person or Group with multiple selections
  • Choice with multiple selections
  • Lookup with multiple selections
  • Time calculations in Date and Time column
  • Currency columns
  • Location columns
  • Calculated columns
  • Managed Metadata columns

2)       Quick formula reference

  • Choice column

The following formula checks if the choice column [$Category] has a value Product Management:

=if([$Category] == ‘Product Management’, ‘true’, ‘false’)

The following are also valid:

=[$Category] == ‘Product Management’

  • Number column

The following formula checks if the number column [$Flightscost] is less than or equal to 120:

=if([$Flightscost] <= 120, ‘true’, ‘false’)

The following are also valid:

=[$Flightscost] <= 120

You can also do arithmetic calculations, such as adding the value of two columns and checking its sum as given in the following formula:

=if(([$Flightscost] + [$Hotelcost]) > 500, ‘true’, ‘false’)

=([$Flightscost] + [$Hotelcost]) > 500

  • Date column

You can check if the date column [$StartDate] equals a specific date. To do so, it uses the Date() function to convert a given string into a date:

=if([$StartDate] == Date(‘4/6/2020’), ‘true’, ‘false’)

=[$StartDate] == Date(‘4/6/2020’)

An example of checking if the date column [$StartDate] is less than or equal to a specific date:

=if([$StartDate] <= Date(‘4/6/2020’), ‘true’, ‘false’)

=[$StartDate] <= Date(‘4/6/2020’)

You can apply multiple conditions.

=if([$StartDate] >= Date(‘4/6/2020’) && [$EndDate] <= Date(‘6/10/2020’), ‘true’, ‘false’)

=[$StartDate] >= Date(‘4/6/2020’) && [$EndDate] <= Date(‘6/10/2020’)

  • Person column

The following formula checks if an email of person column [$Owner] is equal to a specific user’s email:

=if([$Owner.email] == ‘nestorw@contoso.com’, ‘true’, ‘false’)

=[$Owner.email] == ‘nestorw@contoso.com’

  • Boolean (Yes/No) column

The following formula checks if the Yes/No column [$Promoted] equals a Yes. To do so, it checks for the value true which maps to Yes for users.

=if([$Promoted] == true, ‘true’, ‘false’)

The following are also valid:

=if([$Promoted], ‘true’, ‘false’)

=[$Promoted]

  • Lookup column

The following formula checks if the lookup column [$City] has a value equal to Toronto. To do so, it splits the lookup value result by the separator and checks against the value.

=if(substring([$City],indexOf([$City],’;#’)+2,1000) == ‘Toronto’, ‘true’, ‘false’)

= substring([$City],indexOf([$City],’;#’)+2,1000) == ‘Toronto’

Similarly, you can compare against the ID portion of the lookup using this expression:

=if(Number(substring([$City],0,indexOf([$City],’;#’))) == 1, ‘true’, ‘false’)

= Number(substring([$City],0,indexOf([$City],’;#’))) == 1

đź’ˇNote

When accessing lookup columns in a column or view formatting, you can access the lookup value and lookup id as separate values. In form formatting and conditional field expressions, both values are returned as a single line of text. For instance, a lookup column referencing an item with item ID 1 (in the source list) with a value of Toronto will have a value of 1;#Toronto when used in form formatting or conditional field expressions.

  • Nested function

You can use one if function within another if function.

=if([$Category] == ‘Product Management’, ‘true’, if([$Flightscost] <= 120, ‘true’, ‘false’))

Refer to: https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/list-form-conditional-show-hide#specify-conditional-formula-to-show-or-hide-columns

Leave a Reply

Your email address will not be published. Required fields are marked *