cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Warehousing & Analytics
Engage in discussions on data warehousing, analytics, and BI solutions within the Databricks Community. Share insights, tips, and best practices for leveraging data for informed decision-making.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Help with visualization: view only top 10

arindamchoudhur
New Contributor

Hi,

I want to create a visualization where i want to show top 10 playerName with most sum of counter by dayDate.

2025-11-07_14-07.png 

I reached till here. But i don't know how to limit top 10 playerName.

Any help will be highly appreciated.

5 REPLIES 5

szymon_dybczak
Esteemed Contributor III

Oh, maybe there is an easier way to achieve that. According to release notes they've added ability to choose Top or bottom N categories in bar chart. To edit, open the kebab menu for the categorical axis dimension and set the number under Default number of categories:

szymon_dybczak_1-1762522775404.png

 

 

szymon_dybczak_0-1762522713482.png

 

arindamchoudhur
New Contributor

@szymon_dybczak 

 

Default Number of Categories controls the number of dayDate, not the PlayerName.

Sorry, didn't notice that. But still, second approach should work. Here I have parametrized my dataset:

szymon_dybczak_0-1762535211275.png

Then on my bar chart visualization I applied that limit_number parameter. As you can see when I set limit_number = 5 then I 've got top 5 countries with the highest revenue at given year-month:

szymon_dybczak_2-1762535450785.png

 

When I changed my parameter number to 3 I've got different result (top 3 countries this time):

szymon_dybczak_3-1762535504302.png

 

arindamchoudhur
New Contributor

Finally what i did is:

create a new data source with is query:

WITH daily_totals AS (
SELECT
event_date,
playerName,
SUM(counter) AS total_counter
FROM your_table
GROUP BY event_date, playerName
),
ranked AS (
SELECT
event_date,
playerName,
total_counter,
ROW_NUMBER() OVER (
PARTITION BY event_date
ORDER BY total_counter DESC
) AS rn
FROM daily_totals
)
SELECT
event_date,
playerName,
total_counter
FROM ranked
WHERE rn <= 10
ORDER BY event_date, total_counter DESC;

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now