Lesson 15 Creating Custom Visuals in Power BI: A Beginner’s Guide

Lesson 15 Creating Custom Visuals in Power BI: A Beginner’s Guide

Welcome back to Virvijay.com, where we help you master Power BI one step at a time. While Power BI offers a robust library of built-in visuals, there may be situations where default options don't fully meet your needs. This is where custom visuals come into play.

In today’s blog, we’ll guide you through the process of creating and using custom visuals in Power BI, allowing you to take your reports to the next level.


Why Use Custom Visuals in Power BI?

Custom visuals offer several benefits:

  • Unique Insights: Tailor visuals to match specific business requirements.
  • Enhanced Interactivity: Add features not available in built-in visuals.
  • Brand Alignment: Customize visuals to align with your organization’s branding.

1. Power BI Marketplace: An Easy Start

If you’re not ready to create your own visuals from scratch, the Power BI AppSource Marketplace offers hundreds of pre-built custom visuals created by Microsoft and third-party developers.

Steps to Import a Custom Visual from the Marketplace:

  • Open Power BI Desktop.
  • Navigate to the Visualizations Pane and click on the three dots (…).
  • Select Get more visuals.
  • Browse or search for a visual, such as KPI Matrix or Timeline Slicer.
  • Click Add to import it into your Power BI project.

2. Building Your Own Custom Visuals

For advanced customization, you can create your own visuals using the Power BI Developer Tools (pbiviz). Follow these steps to get started:

Step 1: Install Power BI Developer Tools
  • Install Node.js (required for development). You can download it here.
  • Install the Power BI Visual Tools using this command in your terminal:
bash

npm install -g powerbi-visuals-tools

Step 2: Set Up a New Visual Project
  • Create a new folder for your project.
  • Open a terminal in the folder and run:
bash
pbiviz new MyCustomVisual

This initializes a new Power BI visual project.

Step 3: Develop Your Custom Visual
  • Navigate to your project folder:
bash
cd MyCustomVisual
  • Open the folder in your favorite code editor (e.g., Visual Studio Code).
  • Edit the src/visual.ts file to define how your custom visual behaves.
Example Code: Simple Bar Chart

Here’s a basic example of creating a bar chart:

Typescript
import * as d3 from "d3";
import powerbiVisualsApi from "powerbi-visuals-api";

export class Visual implements powerbiVisualsApi.extensibility.visual.IVisual {
    private svg: d3.Selection<SVGSVGElement, unknown, HTMLElement, any>;

    constructor(options: powerbiVisualsApi.extensibility.visual.VisualConstructorOptions) {
        this.svg = d3.select(options.element).append("svg");
    }

    public update(options: powerbiVisualsApi.extensibility.visual.VisualUpdateOptions): void {
        const width = options.viewport.width;
        const height = options.viewport.height;
        
        this.svg
            .attr("width", width)
            .attr("height", height)
            .append("rect")
            .attr("width", width / 2)
            .attr("height", height / 2)
            .attr("fill", "blue");
    }
}


Step 4: Test Your Visual

1. Run the following command to start a test server:

bash
pbiviz start

2. Open Power BI Desktop and navigate to Options > Security > Enable Developer Mode.
3. Import your custom visual from the test server.

Step 5: Package and Publish

Once your visual is ready:

1. Package it with:

bash
pbiviz package

2. Share it with your organization or publish it to the Power BI Marketplace.

3. Best Practices for Custom Visual Development
Focus on Performance:
  • Use lightweight libraries like D3.js to minimize lag.
Make It Interactive:
  • Add tooltips, animations, and slicer compatibility.
Test Across Data Scenarios:
  • Ensure your visual works with small and large datasets.
Follow Microsoft Guidelines:
4. Examples of Popular Custom Visuals

To inspire your creativity, here are a few popular Power BI custom visuals:

Gantt Chart:
  • Ideal for project management and tracking timelines.
Bullet Chart:
  • A compact way to display performance against a target.
Word Cloud:
  • Visualize text-based data with word clouds.
Heatmap:
  • Analyze data density with color gradients.
5. Sharing and Distributing Custom Visuals

Once you’ve created your custom visual, you can distribute it in two ways:

I. Organization-Wide:
  • Share the .pbiviz file with your team for internal use.
II. Public Marketplace:
  • Submit your visual to the Power BI Marketplace for global access.
Steps to Submit to the Marketplace:

  • Package your visual using the pbiviz package command.
  • Go to the Microsoft Partner Center and submit your visual for review.
What’s Next?

Now that you know how to create and use custom visuals in Power BI, the possibilities are endless. In our next blog, we’ll dive into Data Security and Row-Level Security (RLS) in Power BI, a critical topic for ensuring your reports are secure and user-specific.

Final Thoughts

Custom visuals are a powerful way to enhance your Power BI reports and dashboards. Whether you use pre-built visuals from the marketplace or build your own from scratch, these tools allow you to tell your data story in innovative ways.

At Virvijay.com, we’re committed to providing high-quality, actionable insights to help you excel in Power BI. Don’t forget to bookmark this page and share it with your peers. Let’s keep learning together!

Write Us @ [support@virvijay.com]

एक टिप्पणी भेजें

0 टिप्पणियाँ
* Please Don't Spam Here. All the Comments are Reviewed by Admin.