Create a formatted name column

  • The goal of this example is to implement a formatted name using the existing name (first, middle, and last) and Title columns of a customer dimension
  • The target format is Mr. John A. Doe
  • The query must account for nulls in the Middle Name and Title columns as well as different values in the Middle Name column:
  1. Use Table.SelectColumns() to retrieve the required source columns.
Figure 103: Name Columns
  1. Write a Table.AddColumns() function with an if...then expression that accounts for the different scenarios:
Figure 104: Formatted Name Column Expression
  • Text.Range() is used to extract the first character of the middle name.
Figure 105: Formatted Name Column
  • The three if...then conditions account for all scenarios to return the formatted name as per the requirements defined in step 1.