TOPNSKIP DAX Function (Table manipulation)

Retrieves a number of rows from a table efficiently, skipping a number of rows. Compared to TOPN, the TOPNSKIP function is less flexible, but much faster.

Syntax

TOPNSKIP ( <Rows>, <Skip>, <Table> [, <OrderBy_Expression> [, [<Order>] [, <OrderBy_Expression> [, [<Order>] [, … ] ] ] ] ] )
Parameter Attributes Description
Rows

Number of rows to return

Skip

Number of rows to skip

Table
Iterator

Table expression made by physical columns of the data model that are not grouping the cardinality of the original table they belong to.

OrderByExpression
Row Context
Optional

Expression used to define the sort order of the result

Order Optional

It can be ASC or 1 or TRUE to consider the OrderByExpression in an ascending order.
It can be DESC or 0 or FALSE to consider the OrderByExpression in a descending order.
If omitted, the default is descending (DESC).

Return values

Table An entire table or a table with one or more columns.

The table returned is not sorted, it is just filtered according to the required parameters.
The sort order of the result depends on the ORDER BY condition of EVALUATE.

Remarks

If Skip is not 0, the Table expression must reference physical columns with lineage and does not support a filter context coming from context transition.

If there is a tie, in OrderBy_Expression values, at the N-th row of the table, then all tied rows are returned. Then, when there are ties at the N-th row the function might return more than n rows.

If N_Value is 0 (zero) then TOPN returns an empty table.

TOPNSKIP does not guarantee any sort order for the results.

» 1 related article

Examples

--  TOPNSKIP quickly retrieves rows from a table, skipping a 
--  certain number of rows.
--  Mainly used when browsing a table through certains UI.
EVALUATE 
TOPNSKIP ( 
    5,                          -- Rows to return
    0,                          -- Rows to skip
    'Product',                  -- Table
    'Product'[Product Name],    -- Sort order
    ASC                         -- Sort direction
)
ProductKey Product Code Product Name Manufacturer Brand Subcategory Category Color List Price
1037 0401094 A. Datum Advanced Digital Camera M300 Azure A. Datum Corporation A. Datum Digital Cameras Cameras and camcorders Azure 188.50
953 0401010 A. Datum Advanced Digital Camera M300 Black A. Datum Corporation A. Datum Digital Cameras Cameras and camcorders Black 188.50
1023 0401080 A. Datum Advanced Digital Camera M300 Green A. Datum Corporation A. Datum Digital Cameras Cameras and camcorders Green 188.50
967 0401024 A. Datum Advanced Digital Camera M300 Grey A. Datum Corporation A. Datum Digital Cameras Cameras and camcorders Grey 188.50
1009 0401066 A. Datum Advanced Digital Camera M300 Orange A. Datum Corporation A. Datum Digital Cameras Cameras and camcorders Orange 188.50
--  TOPNSKIP is an iterator, the OrderByExpressions are evaluated
--  in the row context generated by TOPNSKIP
EVALUATE
TOPNSKIP (
    5,
    0,
    ADDCOLUMNS (
        SUMMARIZE (
            Sales,
            'Product'[Category],
            'Date'[Calendar Year]
        ),
        "@Sales", [Sales Amount]
    ),
    [@Sales], DESC,
    'Product'[Category], ASC
)
Category Calendar Year @Sales
Home Appliances 2007-01-01 2,347,281.80
Cameras and camcorders 2007-01-01 3,274,847.26
Computers 2007-01-01 2,660,318.87
Home Appliances 2009-01-01 3,290,603.00
Home Appliances 2008-01-01 3,962,572.24

Related articles

Learn more about TOPNSKIP in the following articles:

Last update: Feb 27, 2021   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

2018-2021 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of TOPNSKIP? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.