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
N_Value

The number of rows to return.

Skip_Rows_Value

The 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.

OrderBy_Expression
Row Context
Optional
Repeatable

Expression to be used for sorting the table.

Order Optional
Repeatable

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).

Ties Optional

Function behavior in the event of ties. Skip – ranks that correspond to elements in ties will be skipped; Dense – all elements in a tie are counted as one.

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.

The function does not return ties if the table has columns that can make the rows unique – in that case, it returns the number of rows requested. If the row is duplicated in the table and the tie happens at the N-th row, then all tied rows are returned.

If Rows is 0 (zero) then TOPNSKIP returns an empty table.

TOPNSKIP does not guarantee any sort order for the results.

The TOPNSKIP function works in Excel since version 1809. However, the function is not reported by IntelliSense and it might be not supported in Excel by Microsoft, yet.

TOPNSKIP cannot order by columns that do not have the attribute hierarchy enabled. For example, if a column has the IsAvailableInMDX set to “false”, it cannot be used in the OrderByExpression argument.

» 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: Nov 14, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber, Daniel Otykier

Microsoft documentation not available.
The function may be undocumented or unsupported. Check the Compatibility box on this page.

2018-2024 © 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.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

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.