Matrix in Power BI

Matrix in Power BI

Power BI Matrix and the concept of custom measures are two important features that help users analyze and present the data. The matrix visual in Power BI helps the user to summarize data across multiple dimensions, while DAX in Power BI allows users to create custom formulas called measures. In this blog, let’s explore the matrix table and the creation of a Power BI custom measure in a matrix.

Table of Contents:

What Is the Power BI Matrix Visual?

A Power BI Matrix is a data visualization tool that helps users display data in a grid format. The matrix table supports hierarchical data and can aggregate data at different levels. This makes it ideal for summarizing large datasets and comparing information across multiple dimensions.

Key Use Cases of the Matrix Visual in Power BI Reports

The matrix Table is useful for various reasons:

  • The Matrix Table displays multi-dimensional data such as sales by region and product.
  • It helps in performing operations like sums, averages, and counts.
  • It allows the user to look into specific information by expanding rows and columns.

Matrix vs Table vs Card in Power BI: Key Differences

Here is the key difference of Power BI matrix vs table vs card that is explained in the table.

Feature Matrix Table Card
Structure Matrix has a hierarchical structure with support for grouping. Table has a flat structure and displays only raw data. Card displays a single value, like a KPI, and doesn’t support grouping.
Aggregation Matrix supports aggregations like sum and average. Table displays data without aggregation. Card shows a single aggregated value.
Expand/Collapse Matrix allows the expansion and collapse of data. Table does not support expansion or collapse. Card cannot expand or collapse—it shows one key metric.
Use Case Helps in analyzing multidimensional data. Useful for displaying raw data in rows. Ideal for showing a single summary value.

When to Use Matrix Over Table or Chart Visuals?

  1. Use Matrix for Hierarchical Data Analysis
    The matrix in Power BI is ideal for summarizing hierarchical or multi-dimensional data, such as sales by region, category, and time. It supports data grouping and lets users expand/collapse levels for deeper insight.
  2. Tables Are Best for Viewing Raw Data
    When you need to display unaggregated, detailed records line-by-line, the table visual is more appropriate. Unlike the Power BI matrix visual, tables do not support drill-down or grouping features.
  3. Charts Help Visualize Trends and Comparisons
    Use charts for visual storytelling, highlighting trends, comparisons, or outliers. While visually impactful, charts don’t offer the depth of exploration that a matrix table in Power BI provides.
  4. Matrix Visual Offers Advanced Comparison
    The Power BI matrix visual is effective when comparing multiple metrics across different categories or dimensions. It enables features like conditional formatting and custom subtotals that are not available in tables or charts.
  5. Understand the Difference for Better Visual Choice
    Knowing the difference between table and matrix in Power BI is essential for effective report design. While tables show raw data, and charts emphasize visual summaries, the matrix excels in analytical detail and user interactivity.

What Is a Custom Measure in Power BI and Why Use It?

A Power BI custom measure is a DAX formula used to calculate a value based on the context of a report. It allows users to implement advanced logic, use conditional logic, and create custom calculations for visuals.

How to Create a Custom Measure in Power BI Using DAX?

We will be using a dataset that contains sales data with Amount and weight, and calculate the Weighted Average Sales.

Step 1: Load Your Data into Power BI

Open the Power BI desktop and load your dataset.

loading-data

This is how the data looks after loading it in Power BI.

Step 2: Add a New DAX Measure in Power BI

Click on the New Measure in the Modelling tab. This will open a formula bar where you can write your custom DAX formula in Power BI.

create-measure

Step 3: Write a DAX Formula for the Custom Measure

After clicking on New Measure, a formula bar will open in which you need to write your custom DAX formula in Power BI. We need to calculate the Weighted Average Sales

WeightedAverageSales = 
SUMX(Sales, Sales[Amount] * Sales[Weight]) / SUM(Sales[Weight])

Write this DAX expression into the Formula Bar

DAX Formula

Explanation:

  • SUMX is the function that iterates over the Sales table.
  • Sales[Amount]*Sales[Weight] multiplies the Amount by weight for each row in the table.
  • SUM(Sales[Weight]) gives the sum of all weights.

Step 4: Add Your Measure to the Matrix Visual in Power BI

Select Matrix visual in the visualizations pane and drag the Product field into the Rows section and WeightedAverageSales(new measure) into the Values section.

apply-measure-to-matrix

This is how the Visualization Panel looks, and as you can see, Product is dragged into the Rows section, and the WeightedAverageSales is dragged into the Values Section.

Step 5: Visualize the Output in Power BI Matrix

Resulting Visualization

Explanation: Here, this visualization is called a matrix table, which shows the average sales of each product in Power BI.

How to Format Matrix Visuals in Power BI?

  1. Use the Formatting Pane: Customize fonts, text size, colors, and background to improve readability and match your report’s theme.
  2. Format Row and Column Headers: Style headers for better organization and easier navigation in the Power BI matrix visual.
  3. Set Matrix Column Order: Adjust the Power BI matrix column order to show columns in a logical sequence that makes sense to your users.
  4. Apply Conditional Formatting: Highlight key values using colors or data bars to emphasize metrics like sales targets or KPIs.
  5. Sort by Column Values: Use the Power BI matrix sort by column option to organize data in ascending or descending order for better comparison.
  6. Improve Visual Clarity: Customizing the matrix in Power BI ensures the data is easy to interpret and focused on important insights.

Common Mistakes in Power BI Matrix and How to Fix Them?

1. Overcomplicating DAX formulas

When working with large datasets, writing complicated Power BI DAX formulas reduces performance and slows down report speed. Try to avoid nested functions, and keep your DAX formula in Power BI simple by using variables to store intermediate results.

2. Failing to Handle Blank and Missing Values

Handling null or missing values is very important when you are working with large data. If there are missing values, Power BI might return unexpected results. To handle these values, you can use a Power BI DAX Formula like COALESCE, IFERROR, or ISBLANK.

3. Not Testing Custom Measure

After creating a Power BI custom measure, always test your calculations with different filters and slicers. Make sure that your custom formulas work as expected under various conditions.

4. Ignoring Data Relationship

In Power BI, it is very important to make sure that the data tables are related to each other. If you are working with multiple tables, then make sure that you define the correct relationship between them. If the relationship is not set, then it can result in a wrong matrix.

Best Practices for Using Matrix Visuals and Measures in Power BI

  • Clear Naming: Use relevant names for your custom measures so others can easily understand the logic.
  • Optimize DAX: Make sure custom DAX formulas are optimized to improve report performance.
  • Use Variables in DAX: Improve readability and performance by using variables in DAX expressions.
  • Limit Complex Logic: Avoid complex formulas as they can slow down your reports.
  • Test Custom Measure: Ensure your DAX measure produces the expected results.

Real-World Examples of Matrix Visuals in Power BI

1. Sales Performance by Region and Product
A retail company uses a matrix table in Power BI to display total sales and profit margins by product category and sales region. The Power BI matrix visual allows managers to drill down into each category, helping them compare performance across different locations and make informed decisions.

2. Weighted Average Profitability Analysis
A finance team creates a custom measure in Power BI using a DAX formula to calculate weighted average sales. Displaying this measure in the matrix visual in Power BI helps track profitability trends across departments over time, offering deeper insight into which areas contribute most to revenue.

Conclusion

Power BI’s Matrix visual is combined with a custom measure, providing a powerful way to analyze and visualize complex and multi-dimensional data. By using custom DAX measures, you can create a calculation that suits your specific analysis needs. Understanding the differences between Matrix and other tables, while following best practices, will help you make interactive reports. 

To learn more about Power BI and its functions, check out this Power BI Course and also explore Power BI Interview Questions prepared by industry experts.

Matrix in Power BI – FAQs

Q1. What is a matrix in Power BI?

Matrix in Power BI is used to display data across multiple dimensions.

Q2. How to format a matrix in Power BI​?

You can format a matrix in Power BI by selecting the format visual icon in the visualization pane.

Q3. What is the limit of matrix columns in Power BI?

Matrix columns are limited to 100 columns.

Q4. What are Power BI metrics?

Power BI metrics are KPI(Key Performance Indicators) across specified targets.

Q5. How to create report in Power BI matrix​

Create a matrix report in Power BI by selecting the Matrix visual, then dragging fields into Rows, Columns, and Values.

Q6. How to hide columns in matrix Power BI?

To hide columns in a matrix, use field parameters, conditional measures, or shrink column width via formatting.

Q7. What is a matrix in data visualization?

A matrix in data visualization displays data in a grid format, allowing comparison across multiple dimensions like rows and columns.

Q8. What are the steps to create matrix in Power BI?

To create a matrix in Power BI, select the Matrix visual from the Visualizations pane, then drag fields into Rows, Columns, and Values. You can add multiple fields to each area to enable drill-down and hierarchical views.

About the Author

Data Engineer, Tata Steel Nederland

As a skilled Data Engineer, Sahil excels in SQL, NoSQL databases, Business Intelligence, and database management. He has contributed immensely to projects at companies like Bajaj and Tata. With a strong expertise in data engineering, he has architected numerous solutions for data pipelines, analytics, and software integration, driving insights and innovation.

business intelligence professional