Filter data in a Data view

When you create a Data View, you can apply a filter so that the view includes only data that satisfies the criteria that you specify. For example, you may have a data source that includes hundreds or thousands of records. However, you want to view only a subset of those records. You can create a filter so that only that subset of records is included in your Data View.

When you create a filter, you build one or more expressions that are applied to the data. Data that satisfies these criteria is included in the Data View. There are three basic parts to an expression clause: the field name (the name of the field on which you want to filter), the operator (the rule that you want to apply to the value, such as equal to, greater than, or less than), and the value (the data that you are looking for). You can use multiple expressions in a single filter by adding new clauses that specify additional criteria that the data must satisfy.

When your filter contains multiple clauses, you may want to group two or more clauses so that they are applied before another clause. By determining the order in which the clauses are applied, you have precise control over what data appears in your Data View.

There may be times when you need to create a filter that uses more complex criteria. In Microsoft Expression Web, you can use XPath to create advanced filters. For detailed information about creating XPath expressions, see XPath Reference in the MSDN library.

When you use Expression Web to filter data in a Data View, you limit the records that are actually available in the Data View.

To add a filter to a Data View

  1. In Design view, click the Data View to select it.

  2. On the Data View menu, click Filter.

  3. In the Filter Criteria dialog box, click Click here to add a new clause.

  4. Click the Field Name box, and then click the field that contains the values that you want.

  5. Click the Comparison box, and then click the operator that you want.

  6. Click the Value box, and then type or select the criteria that you want.

To add a clause to a filter

  1. In Design view, click the Data View to select it.

  2. On the Data View menu, click Filter.In the Filter Criteria dialog box, you can see any filter criteria that are currently applied to the Data View.

  3. At the end of an existing clause, click the And/Or box, and then do one of the following:

    • To create a filter where the data must match the criteria in both clauses, click And.

    • To create a filter where the data must match the criteria in only one clause, click Or.

  4. On the next row, click Click here to add a new clause.

  5. Click the Field Name box, and then click the field that contains the values that you want.

  6. Click the Comparison box, and then click the operator that you want.

  7. Click the Value box, and then type or select the criteria that you want.

To group clauses in a filter

  1. In Design view, click the Data View to select it.

  2. On the Data View menu, click Filter.In the Filter Criteria dialog box, you can see any filter criteria that are currently applied to the Data View.

  3. At the end of the second clause, click the And/Or box, and then click Or.

  4. In the Filter Criteria dialog box, click Click here to add a new clause.

  5. Click the Field Name box, and then click the field that contains the values that you want.

  6. Click the Comparison box, and then click the operator that you want.

  7. Click the Value box, and then type or select the criteria that you want.

  8. Hold down SHIFT while you click the arrows in the leftmost column of the clauses that you want to group, and then click Group.The bracket connecting the clauses indicates that those clauses are grouped. To remove grouping, click Ungroup.

To modify a clause

  1. In Design view, click the Data View to select it.

  2. On the Data View menu, click Filter.

  3. In the Filter Criteria dialog box, click an existing clause, and then do any of the following:

    • Click the Field Name box, and then click the field that contains the values that you want.

    • Click the Comparison box, and then click the operator that you want.

    • Click the Value box, and then type or select the criteria that you want.

To delete a clause

  1. In Design view, click the Data View to select it.

  2. On the Data View menu, click Filter.

  3. Click the arrow in the leftmost column of the clause that you want to delete, and then press DELETE.

To delete a filter

  1. In Design view, right-click the Data View, and then click Show Common Control Tasks.

  2. In the Common Data View Tasks list, click Filter.

  3. Hold down SHIFT while you click the arrow in the leftmost column of each clause, and then press DELETE.

Note

If you are using an advanced filter, the text Using advanced expression appears in the Filter Criteria dialog box. To delete an advanced filter, click Advanced, and then delete all text in the text box.

To create an advanced filter

  1. In Design view, click the Data View to select it.

  2. On the Data View menu, click Filter.

  3. In the Filter Criteria dialog box, click Advanced.

  4. In the Advanced Condition 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.

  5. In the Edit the XPath expression box, position the insertion point immediately after the field name, and then press SPACEBAR.The IntelliSense list of available operators appears.

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

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

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

See also

Concepts

Data views

Add a Data view

Apply conditional formatting to a Data view

Sort data in a Data view

Create a formula column in a Data view

Change the layout of a Data view

Modify the columns in a Data view

Add RSS feeds to a page

Display sample data in a Data view