Create a formula column in a Data View

In a Data View, you can create a formula column that displays the result of a calculation that was performed on other data in a data source.

To create a formula column

  1. In Design view, right-click the Data View, point to Insert on the shortcut menu, and then click Column to the Right.

  2. Place the insertion point inside a cell in the new column, right-click inside the cell, and then click Insert Formula on the shortcut menu.

  3. In the Insert Formula dialog box, under Select a field to insert, double-click the field that you want to insert in the expression. To insert the full path of the field, hold down CTRL while you double-click the field.

  4. In the Edit the XPath expression box, position the insertion point immediately after the field name, and then press SPACEBAR. The IntelliSense list of XPath operators appears. IntelliSense for XPath helps you by providing a list of available fields or functions that are valid in the context of the expression.

    Note

    For detailed information about creating XPath expressions, see the XPath Reference Cc295388.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

  5. In the IntelliSense list of operators, double-click the operator that you want.

  6. Press SPACEBAR.

    An IntelliSense list of available fields appears.

  7. In the list of available fields, double-click the field that you want.

    At the bottom of the Insert Formula dialog box, in the Preview area, you can see a preview of the results of the data in the formula column as you build the expression in the Edit the XPath expression box.

  8. Click OK twice.

    A new formula column appears in the Data View. By default, the column header is the expression that you created in the Edit the XPath expression box in the XPath Expression Builder.

  9. To replace the default header, select the column header and then type the text that you want.

See also

Tasks

Add a Data View
Apply conditional formatting to a Data View
Sort data in a Data View
Change the layout of a Data View
Modify the columns in a Data View
Filter data in a Data View
Add RSS feeds to a page
Display sample data in a Data View

Concepts

Data View

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.