# 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

Sam McKay, CFA
Sam is Enterprise DNA's CEO & Founder. He helps individuals and organizations develop data driven cultures and create enterprise value by delivering business intelligence training and education.

## R Scripting For Power BI Using RStudio

In this blog, we’re going to go through the basics of R scripting for Power BI using RStudio. The...

## Simple Aggregations In Power BI

In this blog post, I'll touch on some simple aggregations in Power BI that you can use in your DAX...

## Microsoft Report Builder: Steps In Creating A List

In this tutorial, you will learn how to create a list and page break in Microsoft Report Builder. A...

## 5 Strategies To Enhance Your Power BI DAX Skills

In this tutorial, you’ll learn the general strategies to improve your DAX or M capabilities. This is an...

## ALL Function in Power BI – How To Use It With DAX

Did you know that the ALL function can be used to modify the context of a particular calculation in...

## Calculations In Power BI Using Measure Branching

Measure Branching is a technique in making calculations in Power BI. It's not something you'll hear...

## Power BI Ranking In Hierarchical Form

Today, we will learn how to calculate Power BI ranking in a hierarchical form which is a little bit...

## Understanding Power BI Aggregations

Now, let's delve deeper into one of the most important concepts in Power BI calculations — the...

## Using Python In Power BI | Dataset And String Function

In this tutorial, we'll discuss how you can create and prepare Dataset and String Function using Python...

## Announcing The Enterprise DNA Submit A Showcase Program

Today we are launching a brand-new program here at Enterprise DNA. We are looking to collaborate with...

## Inventory Management Reports To Show Trends In Sales

This Enterprise DNA Power BI Showcase focuses on Inventory Management. You may watch the full video of...

## Huff Gravity Model Analysis in Power BI

In this tutorial, we'll learn how to do a Huff Gravity Model analysis in Power BI. We can use this...