Initial list items
Returns a list that contains the specified number of items at the beginning of a list. If the number of list items to be returned is greater than the length of the list, returns the full list. If the number of list items to be returned is less than 1, returns an empty list.
Sample usage
TOP(LIST("Red", "Yellow", "Green"), 2)
returns a list of 2 items: Red
, Yellow
TOP({"Red", "Yellow", "Green"}, 4)
returns a list of 3 items: Red
, Yellow
, Green
Days of the month
A list of days of a month, accounting for the difference in months:
TOP(
{
1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31
},
EOMONTH([Date], 0)
)
{1, 2, 3, ..., 31}
constructs a list of possible month day numbers.EOMONTH([Date], 0)
identifies the number of the last day of the month specified by theDate
(orDateTime
) value in theDate
column.TOP(..., ...)
returns a list of only the day numbers from 1 to the last day of the given month.
See also: EOMONTH()
Lowest values
The 5 earliest employee hire dates:
TOP(SORT(Employees[Hire Date]), 5)
Employees[Hire Date]
retrieves the list of all values from theHire Date
column of theEmployees
table.SORT(...)
orders the list of dates chronologically in ascending/low-to-high order (the default sort order), putting the earliest dates at the beginning.TOP(..., 5)
returns the first 5 values from the sorted list, the 5 earliest hire dates.
See also: SORT()
Rows with highest values
The rows of the 3 students with the highest GPAs in Mr Sandwich's class:
TOP(
ORDERBY(
FILTER("Students",
AND(
ISNOTBLANK([Teacher]),
([Teacher] = "Mr Sandwich")
)
),
[GPA], TRUE
),
3
)
FILTER("Students", ...)
returns a list of key values from theStudents
table that match a condition.AND(..., ...)
limits the filter to only those rows that match all of the given sub-conditions.ISNOTBLANK([Teacher])
requires theTeacher
column value not be blank.[Teacher] = "Mr Sandwich"
requires theTeacher
column value be exactlyMr Sandwich
.ORDERBY(..., [GPA], TRUE)
orders the filtered keys by the values of their correspondingGPA
column value in descending/high-to-low order (TRUE
), putting high GPAs first.TOP(..., 3)
returns the first 3 items in the ordered list, the keys of the rows having the 3 highest GPAs.
See also: AND()
, FILTER(),
ISNOTBLANK()
, ORDERBY()
Syntax
TOP(list, how-many)
list
- List of any type.how-many
- ANumber
value that specifies the number of item values fromlist
to be returned.