SharePoint Modern view provides an OOTB (Out Of The Box) way to show or hide columns in a List or Document Library form based on value for another field. You can use a formula to perform condition based checks on values in a SharePoint column.
✔️ Steps to show or hide columns on SharePoint from based on condition
- Navigate to your respective list or library.
- Click 'New' or open any List Item (or document properties) to view the Display form.
- Click "Edit form" from the top right corner of the form.
- Click "Edit Columns".
- Click on menu option (...) which is at the far right side of the column name.
- In the dialog popup, enter the custom condition formula, which will show/hide this current column based on the value of another column.
- Click Save.
- Return to your form and test the behavior.
Assume we have a SharePoint List for maintaining project details. The form asks user if 'approval is required ?' (Yes/No field) for the project. If approval required is Yes, then 'Approver Name' field is shown; if No, then the Approver field is hidden.
Use the earlier steps to add conditional formula for the 'Approver Name' column (as this is the field for which we want to toggle the visibility), copy and paste below formula. Change the field name if you are using a different name.
=if([$ApprovalRequired] == true, 'true', 'false')
⭐ Points to consider
- Conditional show/hide of columns works on New and Edit forms, not on display because its only a view form.
- The conditional formula does not work with Quick Edit view (Edit in grid view).
- Comparison and evaluation values true and false are case-sensitive, type in lower case.
- The condition formula works only when it returns true or false values.
- Refer to the field with internal name in this format - [$FieldInternalName].
- This approach hides the respective field in the New/Edit forms and not from the view. To hide the field from the view, modify the view.
- These column types are not supported
- Person or Group with multiple selections
- Choice with multiple selections
- Time calculations in Date and Time column
- Currency columns
- Location columns
- Calculated columns
- Managed Metadata columns
✌️ Conditional formulas examples
Single line of text / Choice - equals
=if([$ProjectCategory] == 'Information Technology', 'true', 'false')
Number - greater, less, equal
=if([$ProjectCost] >= 5000, 'true', 'false')
Number - sum
=if(([$Cost] + [$Tax]) > 1000, 'true', 'false')
Yes/No - Yes or No (boolean)
=if([$ApprovalRequired] == true, 'true', 'false')
Person - email account equals
=if([$Approver.email] == 'c2cAdmin@code2care.com', 'true', 'false')
Date - equal, less, greater (check the date format)
=if([$ProjectKickoffDate] == Date('3/7/2021'), 'true', 'false')
Date - between 2 dates
=if([$ProjectKickoffDate] >= Date('6/10/2021') && [$ProjectKickoffDate] <= Date('7/10/2021'), 'true', 'false')
Lookup - equals (check the lookup value)
=if(substring([$Category],indexOf([$Category],';#')+2,500) == 'Migration', 'true', 'false')
Lookup - equals (check the lookup id)
=if(Number(substring([$Category],0,indexOf([$Category],';#'))) == 1, 'true', 'false')
Have Questions? Post them here!
- PowerShell - How to use Try Catch Finally blocks for error exception handling (Windows/SharePoint)
- SharePoint List excel import - This table exceeds the maximum number of supported rows
- Update SharePoint Online List Item using REST API, HTML, Spfx, Postman
- Fix SharePoint Error - The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started
- SharePoint list excel import error - Title is a required filed and can't be empty
- Move Copy Migrate SharePoint OneDrive files folders to different site collection location
- Create SharePoint list from Excel spreadsheet and import table
- Send Email using SharePoint PowerShell command, SMTP server
- [Fix] Restricted View permission level missing in SharePoint Online site library
- How to get SharePoint List Item URL using PowerShell
- The service instance
- How to get the SharePoint Tenant Login URL
- New-SPLogFile PowerShell - create new SharePoint log file
- Not receiving email notification alert in SharePoint Online workflow - Power Automate, FLOW
- SharePoint Server 2016 Preview installation error - This Product Key isn't a valid Microsoft Office 2016 Product Key. Check that you've entered it correctly.
- How to change order of fields on new item form for SharePoint Online list
- Update Created By (Author) column of SharePoint document using PowerShell
- How to delete SharePoint Online List Item using REST API
- 'Edit Document' Requires a Windows Sharepoint Services-compatible application and Microsoft Internet Explorer 6.0 or higher
- Create SharePoint Site Collection using PowerShell New-SPSite
- How to customize SharePoint Modern list form using JSON formatting
- How to get SharePoint Online user details from person or group column using REST API
- SharePoint excel error - A problem occurred while connecting to the server. If the problem continues, contact your administrator.
- How to create SharePoint List Item programmatically using C#.net
- How to Get or Set SharePoint Document ID _dlc_DocId using PowerShell
- error: file not found: HelloWorld.java - Java
- The Date Command and its usage [Linux - Unix - macOS] - Linux
- SharePoint Managed Metadata Hidden Taxonomy List - TaxonomyHiddenList - SharePoint
- Git: Delete Branch Locally and Remotely at Origin - Git
- Change Max and Min Value of Android Seekbar Programmatically - Android
- Get the current timestamp in Java - Java
- Hyperlink in html (anchor tag) without a underline - Html
- How to migrate SharePoint Designer 2010 workflow to Power Automate FLOW (Microsoft Office 365) - SharePoint