Renaming fields
In the previous topic, we showed you how to rename fields in the data preview window. In the heading of the data preview window, you renamed Invoice Date to Bill Date. When you inserted the load script, you could see that the field would be renamed using the keyword AS.
We can also perform this action directly in the script.
Do the following:
- Open the Data load editor in the Scripting Tutorial app.
- Click the Sales tab.
- In the load script, make the following changes. Note that you have to include parentheses around fields that contain a space.
- Change GrossSales, to:
- Change "Item Desc", to:
GrossSales AS "Gross Sales",
"Item Desc" AS "Item Description",
- Click Load data. The data is loaded.
- Open the Data model viewer. Confirm that the fields have been renamed.
- You can also view all your fields in an app. Click the Analysis/Sheet tab in the top toolbar. The app opens in sheet view.
- Click Edit sheet, and then click Fields in the assets panel. You can see the field names that you changed. You can use any of these fields in the visualizations that you create in your app.
Your script should look like this: