Skip to main content
· 2 min read

New query type: Leaderboard

In addition to counters and time series, we now support leaderboard queries. Leaderboards are great for visualizing the “top N” of something, such as “the top 10 salespeople of the month” or “the top 100 events last year.” You can query it with a timeRange set of dimensions to group on, a sort order, filters, and a lowLimit. For example,

query {
metricByName(uniqueName: "sales") {
leaderboard ({
timeRange: { relative: "THIS_MONTH" },
dimensions: [{ columnName: "SALES_PERSON" }],
rowLimit: 10
}) {
headers
rows
}
}
}

The result you get back is an array of headers and an array of rows:

{
"headers": ["SALES_PERSON", "SALES"],
"rows": [
["Alice", "100"],
["Bob", "99"],
["Carol", "80"],
["Dave", "76"],
["Erin", "75"],
["Frank", "75"],
["Grace", "66"],
["Heidi", "63"],
["Ivan", "34"],
["Judy", "33"]
]
}

Perfect for piping into your favorite graph visualization library! For example, here we use ECharts to visualize a leaderboard from the state of California:

A screenshot of a leaderboard visualization. Rows are labeled with areas from the state of California and are sorted in descending order. A screenshot of a leaderboard visualization. Rows are labeled with areas from the state of California and are sorted in descending order.