# Power BI Percent Of Total – Using CALCULATE Statement

Power BI percent of the total is a really common calculation that we require quite often. This is great to quickly show where the larger portion of results sits versus the entire population.

Completing this in Power BI does not require much-written code, but it does require some understanding. It will generally be one of the first introductions to the CALCULATE statement.

Let’s start by running through an example.

First, let’s create a total sales calculation. This is easy.

Now we can place it next to one of our dimensions, say customers, and we will return the total sales for each customer.

Now, how can we calculate the percent of total? Well, we have to get the sales for ALL customers and somehow place it onto every single row. We need to divide every single total sales result beside each customer by the total for ALL customers.

The only way to do this is to use the CALCULATE function to change the filter context for the total sales measure.

Let’s see what happens when we bring the ‘Sales for ALL Customers’ measure into the table next to customers

So you see that we have achieved what we need. We can now divide the ‘Total Sales’ measure by the ‘Sales for ALL Customers’ measure and get the % of total as the result. Let’s do that.

Great, now we have our results aligned to each customer name. In the results here we can immediately see that the sales are rather distributed across all our customers with the highest customers only having 2.64% associated to them.

We don’t even need these intermediary numbers anymore. We can just show the percentage.

What’s really cool now is we can start slicing the data by some of our other dimensions and get the percent of totals for the new context (our new filters).

Let’s check this out by bringing in products and countries, and see how our results change.

As you can see, the results now dynamically adjust for any selection we make. We can select a country, then a product, and quickly identify who our best customers are for that selection.

I would add here that we achieve these results only because we have written our DAX function using the CALCULATE statement against the Customers context. If we placed this measure against a different dimension like from the regions table of products table, we would receive weird results.

That is why you need to understand the filter context well. It will be something that we will touch on many times over in time.

Good luck on this!

Sam

## Power BI Slicers Tutorial: Counting Selections Correctly

In today's tutorial, I'm going to work through a subtle issue with Power BI slicers that can trip you...

## Time Intelligence In DAX: How To Dynamically Select Starting Period

In this blog post, we will deal with some troublesome issues in time intelligence, particularly those...

## Power BI Themes: User Guide With Examples

Power BI is a powerful business analytics tool that helps you visualize and analyze data from various...

## RANKX Considerations – Power BI And DAX Formula Concepts

RANKX is a very unique DAX function that requires a deeper level of thinking around its logic and...

## Using Filter Fields & Visual Interactions To Create Compelling Visualizations In Power BI

I want to show you how you can use filter fields and visual interactions in Power BI to great effect....

## Show Cumulative Totals Unaffected By Date Slicer Selection In Power BI

In this blog post, you'll learn how to show data from specific time frames as filtered by a date slicer...

## Power BI Port Number: Connecting Power BI To SSAS, Excel, And C#

In this tutorial, you’ll learn how to use a Power BI port number to connect a data model to SSAS,...

## Sorting Date Table Columns In Power BI

In today's blog, I'll discuss a question that comes up all the time in the Enterprise DNA forum. How...

## Filter In Power BI: DAX Queries Context Transition

This post will discuss how to identify a filter via xmSQL and the storage engine query in Power BI....

## How To Work With Multiple Dates In Power BI

As soon as you start developing a few Power BI models, you'll very likely run into a problem where you...

## Power Platform Tutorials: Why Get A Microsoft Power Platform Certification?

Power Platform Tutorials For this blog post, I'll be talking about Microsoft certifications related to...

## Customer Analysis In Power BI; Reviewing Performance Over Time

Customer analysis is a crucial thing to do for any business specially if you have a large number of...