Deneb Showcase: Visualize Every Detail with Unit Charts in Power BI
The visual on the right is from Hospara, Inc and the one on the left, I created using Deneb.

Deneb Showcase: Visualize Every Detail with Unit Charts in Power BI

Inspired by detailed stacked visuals like the equipment risk chart shown from the Hopara, Inc. website. Hopara - Real-Time Data Visualization for Power BI)


Ever look at a standard bar chart showing aggregated counts and wish you could see the individual components making up those totals? While great for summaries, aggregated charts sometimes hide the underlying detail. But what if you could visualize every single data point while still keeping the structure of a stacked bar chart?

With the power of Deneb and Vega-Lite inside Power BI, you can! Today, I'll walk through creating a stacked unit chart. Imagine stacked bars where, instead of solid colored blocks, each bar is composed of tiny, distinct rectangles. Each rectangle represents one individual item (like a piece of equipment), colored by a category (like risk score), and grouped by another category (like device type).

This approach allows viewers to grasp both the overall distribution and the contribution of individual items. Let's dive in!

Step 1: Get Your Data Ready

Before we jump into Deneb, pristine data is key, especially for this technique. You'll need a table in Power BI with at least these columns for each individual item you want to plot:

  • Unique ID Field (e.g., EquipmentId): Absolutely essential. Each item needs a distinct identifier so we can reference it (especially in tooltips).
  • Grouping Category Field (e.g., DeviceType): This determines the main bars along the X-axis.
  • Stacking & Coloring Field (e.g., RiskScore): This determines the color of each small rectangle and how they stack within the bars. CRITICAL: This field must contain clean, sortable data (like numbers 1-10). Blanks, nulls, or mixed text/numbers will likely cause the visualization to fail because the code needs to sort these values precisely to stack the rectangles correctly.

Step 2: Set Up Your Deneb Visual

  1. Add the Deneb visual to your Power BI report page.
  2. Select the visual.
  3. In the Visualizations pane, drag your Unique ID, Grouping Category, and Stacking/Coloring fields into the "Values" well.

Step 3: The Magic - Deneb & Vega-Lite Code

Now for the fun part! Edit the Deneb visual and replace the contents with the following Vega-Lite JSON specification. Remember to replace EquipmentId, DeviceType, and RiskScore in the code with your actual field names!

Article content

How it Works - The Key Concepts:

  • No Aggregation: Unlike standard bar charts, we tell Vega-Lite to draw a rect mark for every single row of data.
  • Transformations are Key: We calculate the total count per DeviceType only so we can sort the main bars later. The crucial stack transform calculates the precise Y-coordinate (y_start, y_end) for each item's rectangle, ensuring they stack neatly within their DeviceType bar, ordered by RiskScore. This step demands clean, sortable RiskScore data.
  • Encoding: We map DeviceType to the X-axis, the calculated y_start/y_end positions to the Y-axis, and RiskScore to color. The tooltip is configured to show the specific EquipmentId of the rectangle you hover over.

Troubleshooting Tips:

  • Yellow Bars / "Undefined"? Almost always means an issue with the RiskScore field. Double-check the exact field name (case-sensitive!) in the code matches Power BI, AND inspect the RiskScore column for any blanks, nulls, or non-sortable text values. Clean the data!
  • Chart Not Appearing? Ensure all needed fields (EquipmentId, DeviceType, RiskScore) are actually dragged into the "Values" well of the Deneb visual in Power BI.

Try It Out!

This unit chart technique provides fantastic visual density and allows exploration of individual data points within broader categories. Give it a try with your own datasets where seeing the individual components matters. Happy visualizing! If you have any questions, feel free to message me.

Mahesh Kumar

Power BI developer| SQL| Azure Synapse| ADF | Data Analysis| SQL|Data Factory| PySpark | Data Warehousing

4mo

Where to get the code

Like
Reply
Kedeisha Bryan

I used to deliver pizzas, now I deliver insights | I help career changers launch $100k analytics careers without going back to school

4mo

Interesting it seems there's been a movement to replace the standard stacked bar chart lately lol

Kedeisha Bryan

I used to deliver pizzas, now I deliver insights | I help career changers launch $100k analytics careers without going back to school

4mo

Hmmmm....that's the first time I've seen such a bar chart on the right

Christine Payton

Microsoft MVP, Data Platform | 🪼 Power BI | Tutorials on YouTube

4mo

This is neat - do you have the text for the JSON posted somewhere, or is this an OCR situation?

To view or add a comment, sign in

Others also viewed

Explore topics