Summary
How do you extend an existing Databricks dashboard with new data?
- Open SQL → Dashboards, select the existing dashboard and switch to Edit draft.
- Use Catalog Explorer to inspect
databricks_simulated_retail_customer_data.v01.sales,.customers, and.sales_orders, including available columns and data types. - Open the dashboard’s Data tab and select Create from SQL to build datasets using joins, aggregations, or common table expressions (CTEs).
- Give each dataset a meaningful name, Run its SQL to verify the result, then select the dashboard canvas to add visualizations based on those datasets.
- After changing charts or filters, Publish again; draft changes are not automatically visible in the published dashboard.
How do you combine sales and customer information for a loyalty analysis?
- Create a SQL dataset named Sales by loyalty segment. Join
salestocustomerson their sharedcustomer_idto associate purchase amounts with loyalty segments.
SELECT
s.product_category,
c.loyalty_segment,
s.total_price
FROM databricks_simulated_retail_customer_data.v01.sales AS s
JOIN databricks_simulated_retail_customer_data.v01.customers AS c
ON s.customer_id = c.customer_id;- An INNER JOIN returns only records with matching customer IDs in both tables. Use aliases (
s,c) to make column origins clear. - Confirm the join key is unique on the customer side; duplicate customer records could multiply sales rows and inflate totals.
- Add a Heatmap widget: dataset Sales by loyalty segment, X axis
product_category, Y axisloyalty_segment, and colour measureSUM(total_price). - Darker or stronger colours indicate larger aggregate spending according to the chosen colour scale; check the legend before interpreting patterns.
How do you combine sales amounts and order counts by day?
- Create a dataset named Sales and orders by day. Use CTEs (
WITH ... AS) to calculate sales totals and order counts separately, then join their results. - The following reproduces the course’s day-of-month comparison; it combines the same day number across all months in the data.
WITH sales_data AS (
SELECT
DAY(order_date) AS day,
SUM(total_price) AS total_sales
FROM databricks_simulated_retail_customer_data.v01.sales
GROUP BY DAY(order_date)
),
orders_data AS (
SELECT
DAY(FROM_UNIXTIME(TRY_CAST(order_datetime AS BIGINT))) AS day,
COUNT(order_number) AS total_orders
FROM databricks_simulated_retail_customer_data.v01.sales_orders
GROUP BY DAY(FROM_UNIXTIME(TRY_CAST(order_datetime AS BIGINT)))
)
SELECT s.day, s.total_sales, o.total_orders
FROM sales_data AS s
JOIN orders_data AS o ON s.day = o.day
ORDER BY s.day;SUM(total_price)calculates revenue;COUNT(order_number)counts non-null order numbers;TRY_CASTreturns null rather than raising an error for values that cannot be converted to integers.- Important:
FROM_UNIXTIMEassumes the source value is a Unix timestamp in seconds. Verify whetherorder_datetimeactually uses seconds, milliseconds, or a timestamp/string before using this conversion. - For real daily trends, group and join by full calendar date, not just
DAY(...); otherwise, the 1st of January and the 1st of February are merged. Check both tables’ date ranges and grain before comparing totals. - Add a Line chart: dataset Sales and orders by day, X axis
day(no transformation), and Y seriesSUM(total_sales)andSUM(total_orders). Enable dual axis to show dollars and order counts on separate scales. - Dual axes make differently scaled measures visible together, but can exaggerate apparent relationships; label both axes clearly.
How do you make new charts respond to dashboard filters?
- In Edit draft, select the existing Product Category filter and open its configuration panel.
- Under Fields, add
Sales by loyalty segment.product_categoryalongside the existing product-category fields. - A field filter only affects datasets/visualizations whose relevant fields have been configured for that filter. The Sales and orders by day dataset has no
product_categoryfield, so the existing category filter cannot directly filter that chart. - To make the day chart respond to category selection, redesign its dataset to preserve or parameterize category filtering before aggregation, then configure the filter accordingly.
- Test the filter against each intended chart and republish the dashboard to make the changes available to viewers.
What should you check before sharing the finished dashboard?
- Verify the SQL results, joins, aggregations, dates, axis labels, and visualizations against the source data.
- Confirm the dashboard’s SQL warehouse, sharing settings, and data-permission mode are appropriate for its audience.
- Use Publish to update the published version, then switch to View published to confirm the charts and filters work for viewers.
- Use Genie alongside dashboards when users need natural-language follow-up questions; review its data sources, instructions, generated SQL, and access permissions separately.