---
schema_version: "1"
id: 185b36948558ef609abe7b3582cb126eb10cf71c964e4e2c175dc1fcecf36873
title: TopRows Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_reports_TopRows.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2c23c4d9c86b5a1e0477f9f967c070ab42a9419a49e65a64c2e79141830f5456
description: Contains methods and constructors for working with information about a row limit filter.Creates an instance of the Reports.TopRows class using the specified parameters.Creates an instance of the Reports.TopRows class. You can then set values by using the class’s set methods.Returns the sort order of the report rows.Returns the maximum number of rows shown in the report.Sets the sort order of the report’s rows.Sets the sort order of the report’s rows.Sets the maximum number of rows included in the report.Returns a string.
---
# TopRows Class

Contains methods and constructors for working with information about a row limit filter.

## Namespace

[Reports](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Reports.htm "The Reports namespace provides classes for accessing the same data as is available in the Salesforce Reports and Dashboards REST API.")

- **[TopRows Constructors](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_constructors)**
- **[TopRows Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_methods)**

## TopRows Constructors

The following are constructors for TopRows.

- **[TopRows(rowLimit, direction)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_ctor)**  
    Creates an instance of the Reports.TopRows class using the specified parameters.
- **[TopRows()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_ctor_2)**  
    Creates an instance of the Reports.TopRows class. You can then set values by using the class’s set methods.

### TopRows(rowLimit, direction)

Creates an instance of the Reports.TopRows class using the specified parameters.

#### Signature

public TopRows(Integer rowLimit, Reports.ColumnSortOrder direction)

#### Parameters

- **rowLimit**:
    
    Type: [Integer](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_integer.htm#apex_methods_system_integer "Contains methods for the Integer primitive data type.")
    
    The number of rows returned in the report.
- **direction**:
    
    Type: [Reports.ColumnSortOrder](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_reports_columnsortorder.htm#apex_enum_reports_columnsortorder "The Reports.ColumnSortOrder enum describes the order that the grouping column uses to sort data.")
    
    The sort order of the report rows.

### TopRows()

Creates an instance of the Reports.TopRows class. You can then set values by using the class’s set methods.

#### Signature

public TopRows()

## TopRows Methods

The following are methods for TopRows.

- **[getDirection()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_getDirection)**  
    Returns the sort order of the report rows.
- **[getRowLimit()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_getRowLimit)**  
    Returns the maximum number of rows shown in the report.
- **[setDirection(value)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_setDirection)**  
    Sets the sort order of the report’s rows.
- **[setDirection(direction)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_setDirection_2)**  
    Sets the sort order of the report’s rows.
- **[setRowLimit(rowLimit)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_setRowLimit)**  
    Sets the maximum number of rows included in the report.
- **[toString()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_reports_TopRows.htm#apex_reports_TopRows_toString)**  
    Returns a string.

### getDirection()

Returns the sort order of the report rows.

#### Signature

public Reports.ColumnSortOrder getDirection()

#### Return Value

Type: [Reports.ColumnSortOrder](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_reports_columnsortorder.htm#apex_enum_reports_columnsortorder "The Reports.ColumnSortOrder enum describes the order that the grouping column uses to sort data.")

### getRowLimit()

Returns the maximum number of rows shown in the report.

#### Signature

public Integer getRowLimit()

#### Return Value

Type: [Integer](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_integer.htm#apex_methods_system_integer "Contains methods for the Integer primitive data type.")

### setDirection(value)

Sets the sort order of the report’s rows.

#### Signature

public void setDirection(String value)

#### Parameters

- **value**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")
    
    For possible values, see [Reports.ColumnSortOrder](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_reports_columnsortorder.htm#apex_enum_reports_columnsortorder "The Reports.ColumnSortOrder enum describes the order that the grouping column uses to sort data.").

#### Return Value

Type: void

### setDirection(direction)

Sets the sort order of the report’s rows.

#### Signature

public void setDirection(Reports.ColumnSortOrder direction)

#### Parameters

- **direction**:
    
    Type: [Reports.ColumnSortOrder](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_reports_columnsortorder.htm#apex_enum_reports_columnsortorder "The Reports.ColumnSortOrder enum describes the order that the grouping column uses to sort data.")

#### Return Value

Type: void

### setRowLimit(rowLimit)

Sets the maximum number of rows included in the report.

#### Signature

public void setRowLimit(Integer rowLimit)

#### Parameters

- **rowLimit**:
    
    Type: [Integer](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_integer.htm#apex_methods_system_integer "Contains methods for the Integer primitive data type.")

#### Return Value

Type: void

### toString()

Returns a string.

#### Signature

public String toString()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")