
Adding a column
Columns in lists define the nature and type of information that is stored in those lists. We briefly saw how to create new columns on a custom list as part of the Creating a list recipe in Chapter 2, Introduction to SharePoint Online.
In this recipe, we'll see how to add a new column to the Marketing Announcements list that we just created. We will add a new Announcement Start Date column to the list. We will then discuss some more advanced concepts around column creation in the sections to follow.
Getting ready
You will needEdit, Design, or Full Control permissionsin your site to be able to add columns to your list.
How to do it...
To add a new column to your list:
Browse to the list for which you would like to add the new column.
Click Add column to see a list of the types of columns that you can add to the list.
Click Date to create a column that lets you store dates or date-time values.
In the Create a column window, enter or select values for various column properties, as shown in the following screenshot:

Click the Save button to save the properties and create your new column.
That's it! You just learned how to create a new column to your list.
How it works...
Columns allow for information to be associated with individual items in your list. For document libraries, they act as metadata that gets associated with the respective documents. Just as with columns in an Excel worksheet, SharePoint lists and libraries let you specify the type of information these columns can hold. Similarly, you can sort, filter, and group information using columns in SharePoint.
SharePoint supports various types of columns, as shown in the following screenshot:

After you select a column type, you can choose to specify additional properties for that column. For example, for the Single line of text column type, you can specify the maximum number of characters that the users can enter (with an upper limit of 255 characters). In addition to such column-specific properties, SharePoint also lets you specify some common properties, such as whether or not this will be a required column. You can view detailed descriptions of the different types of columns and their properties through this support article: https://m365book.page.link/Column-types.
Once a column is created, you can view and edit any of its properties through the List settings page. This is also where you can delete the column if you no longer see the need for it. The List settings page also lets you specify the order of columns to be shown in the data entry form. The Viewing and changing list settings recipe later in this chapter covers the List settings page in greater detail.
There's more...
In this section, we will learn about a few more actions that you can perform with columns. We will also learn about how to make your columns reusable across various lists and libraries in your site through the use of Site Columns.
Editing or deleting a column
Once a column is created, you can easily make changes to it, or even completely delete it. To do so, simply click on the column name, then click Column settings and then Edit to view the column in Edit mode:

This will show you the Edit column screen, just like the one you saw when creating the columns. Here, you can make changes to the column and then click Save to save those changes. You can also delete the column by simply clicking the Delete button toward the bottom of the screen:

Clicking More options from the Edit column screen lets you set additional properties for the column:

As shown in the preceding screenshot, in addition to specifying whether or not the column is mandatory and whether it should enforce unique values, you can also set validation for the values that the column would allow. In the example from this screenshot, we are validating for the start date to be greater than or equal to today's date (the date on which the item is being created or edited). We are also providing a message that SharePoint will display to users if the selected start date does not meet the validation criteria.
Other column settings
In addition to editing a column, clicking on Column settingslets you perform a couple of other actions with the column:

Here's a brief description of these settings:
Format this column: Column formatting lets you customize the display of columns within the list or library. Column formatting is very similar to view formatting, which we have described in greater detail as part of the Advanced view formatting topic in the next recipe, Creating a custom list view. You can read more about column formatting here: https://m365book.page.link/About-Column-formatting. You can read more about using column formatting to customize SharePoint here: https://m365book.page.link/use-column-formatting.
Move left/Move right: Moves the column toward the left or right in the view. You can also simply drag the column to reposition it within the view.
Hide this column: Hides the column from the current view. The column can still be available through other views and/or forms.
Pin to filters pane: This allows the column to be pinned to the filters pane for the view. We have discussed this in more detail through the Filters pane topic in the next recipe, Creating a custom list view.
Show/hide columns: Clicking this option opens a list of all the columns from the list or library and enables you to select or deselect columns to be shown in the current view.
Add a column: You can add a new column to the list using this option.
Site Columns
One disadvantage of creating columns the way we have created them previously is that they are local to that list or library. This means if someone else needs a similar column in another list or library in the site, they will have to create a similar column elsewhere. In addition to effort duplication, this also often leads to inconsistencies between columns that are similar to each other but have subtle differences because they were created independently of each other. These inconsistencies are further amplified in Choice type fields where users have to select one value from a list of predefined values. For example, one list could contain Human Resources as a department, while another list could contain HR as a choice for the department name. Furthermore, let's say you need to make modifications to such a column that is replicated across multiple lists or libraries. You will now need to do that in multiple places.
This is whereSite Columns shine compared to individual list or library columns. Site Columns are similar to list or library columns, only that that they are defined and maintained at the site level. You will need Design or Full Controlpermissions on the site to be able to create Site Columns.
You can create Site Columns by browsing to the Site Settings page and then clicking the Site Columns link under the Web Designer Galleries heading. We discussed the Site Settings page as part of the Viewing and changing site settings recipe in Chapter 3, Working with Modern Sites in SharePoint Online. Once you are on the Site Columns page, you will see a list of the existing Site Columns for your site. You will also be able to click on the Create link on the top of the page to create a new Site Column:

From this point on, the steps to create the Site Column will be similar to those earlier in the recipe. The only difference will be that you will be prompted to choose a Groupfor your Site Column, as shown in the following screenshot:

A Group is just a logical means of grouping Site Columns under one heading. It does not have any impact on the functionality of the Site Column. Once your Site Column is created, you can go back to your list and add it to the list through the Add from existing Site Columnslink on theList settings page. We will discuss the List settings page in more detail in the Viewing and changing list settings recipe later in this chapter.
See also
The Creating a list recipe in Chapter 2, Introduction to SharePoint Online
The Viewing and changing site settings recipe in Chapter 3, Working with Modern Sites in SharePoint Online
The Viewing and changing list settings recipein this chapter
The Creating a Managed Metadata Site Column recipe in Chapter 6, Term Store and Content Types in SharePoint Online