Create a column from an example
Applies To
Excel for Microsoft 365Let’s add several columns to deconstruct different date types from the existing Order Date field. For example, you may want to identify the day of the week or spell out a date such as Monday, January 15th.
-
Select the "Order Date" column.
-
Select Add Column > Column From Example > From Selection, and then type "January".
-
If you prefer the suggestion, press Enter and then select OK.
-
Power Query automatically renames the column to "month name".
-
Select the Order Date column, add a new column, enter "Day", and then select Monday from the list.
-
Power Query fills the column with day names and renames the column "Day Name".
-
To teach Power Query to recognize patterns, do the following:
-
Select "Order Date column" and then add a new column.
-
Enter "Monday, January 15th, 2018", which corresponds with that row's date, and press Enter.
If nothing happens, then copy the date you just entered and paste it in the row below. This time, Power Query has determined to do something with the Order Date, but not what. -
Press Enter, then go to the third row and enter "Saturday, January 20, 2018".
-
Power Query fills in the date pattern, but the dates aren't quite correct, so let’s continue to teach the pattern.
-
Double-click the fourth row and replace "January" with "February".
-
Press Enter. Power Query figures out the pattern and applies it to the rest of the rows.
-
-
To return the transformed data to an Excel worksheet, select Home > Close & Load.
Note If you still want to change the header row, name it to "Custom Date", for example.