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
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. |
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
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.
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:
-
Querying raw data to Tabular
This article describes how to extract raw data stored in the Tabular engine, used by Analysis Service Tabular, Power BI, and Power Pivot. » Read more
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.