โ10-14-2024 04:58 AM
In a Databricks AI/BI dashboard, I have a field with multiple categories (e.g., district-wise sales with 50 districts). How can I display only the top few categories (like the top 10) based on a specific metric such as sales?
โ10-16-2024 07:10 AM
hello @Akshay_Petkar,
in your data tab, can't you create a dataset using "Create From SQL" and write a query like the following and use this dataset in your canvas?
โ10-16-2024 08:26 PM
Hello @Mo
I am creating a AI/BI dashboard where I need to add multiple charts, each showing the top 10 values. For example, I used a query like select * from table and in the canvas, I added a chart with 50 unique values, but I want to display only the top 10. In another chart, there are 100 unique values, and again, I need to show the top 10 only. How can I apply this limit across all the charts?
โ11-21-2024 02:36 PM
I was having the same question and creating a new SQL dataset for this breaks cross filtering. Since the data is coming from different datasets cross filtering does not work nicely
Is there a more elegant solution to this?
โ12-10-2024 01:02 AM
in the AI/BI dashboards in your data, add a limit parameter like:
select all from my_table limit :limit_number
to all your tables.
when you're on canvas and adding visualizations, add a filter and create a parameter with single value:
Then you can use that parameter to limit the numbers you're displaying for all the visuals that have that parameter in the limit. here I used the tables in samples.tpch and limit the numbers to 3 rows:
and this a sample query on orders table:
SELECT * FROM samples.tpch.orders limit :limit_number
let me know if this helps or you have doubts.
โ02-10-2025 07:39 PM
Hi @Mo ,
The parameter limits the rows from the dataset that we read in the query. For example, We create a city-wise sales chart at that time, it aggregates the values and performs a group by. This parameter will not perform on that. It will limit only the rows from the dataset
โ04-16-2025 02:43 AM
Did you find a solution?
2 weeks ago
i got a similar challenge of displaying top 10 rows based on a metrics?
2 weeks ago - last edited 2 weeks ago
@GunaR is this not where we'd want to leverage a parameter? And then pair this with a filter on the dashboard? Perhaps you create an aggregate SQL query for the various metrics
If you can't use a parameter in the ORDER BY clause, which you likely can't because you want a column name to to be output from the parameter, you could use something like this:
I think the CASE statement is a good workaround as a parameter will output a string field. The CASE statement then points it back to the column reference.
Make the parameter a choice and then the user will be able to select the appropriate metric to ORDER BY? In a LIMIT clause, you then just specify a numeric parameter with the appropriate number so they can limit top N
All the best,
BS
2 weeks ago
Thank you for the prompt response.
Good that Parameter helps to make the sort dynamic, In my case i got a common dataset which get used across all the pages in the dashboard. Only few widgets need to limit the top 20 records ordered by certain column, rest all should return all the rows.
Passionate about hosting events and connecting people? Help us grow a vibrant local communityโsign up today to get started!
Sign Up Now