How to compute earnings margin in Microsoft Power BI utilizing a computed column


a magnifying glass resting on top of a data report Image: StackCommerce Profit drives companies, big and little, so you’ll most likely need a visual that shows your company’s profit margin effectively. The bright side is visualizing earnings margin is simple in Power BI if you have all of the details you need. The bad news exists’s no single service for determining revenue margin, due to the fact that every business is various. Knowing the logic behind your company’s organization guidelines is a should if you want to create the ideal estimation(s).

SEE: Hiring package: Microsoft Power BI designer (TechRepublic Premium)

In this tutorial, I’ll show you how to add a calculated column utilizing DAX to show the earnings margin in an Adventure Works visual. I’m using Microsoft Power BI on a Windows 10 64-bit system. You can download the demonstration.pbix file, Adventure Functions Sales, from GitHub. Once downloaded, double-click the.pbix file to open it in Power BI and follow along or use a.pbix file of your own. If you want a preview at the results, have a look at this demo file.

Dive to:

How to find the best revenue formula

Before we get going with determining our revenue margin, let’s make certain we comprehend what we’re determining. For beginners, there are three types of profit to consider:

  • Gross margin: Represents our formula, which subtracts expenses of items and working from earnings.
  • Operating earnings: The outcome of subtracting all running expenses from the gross margin.
  • Net earnings: The outcome of subtracting all taxes and financing costs from operating costs. This outcome is the most detailed when assessing a business’s revenue or profitability.

Adding revenue to a visual, when asked, will require a little bit of sleuthing on the designer’s part, unless the person asking supplies all needed information upfront. It’s not likely that many designers would have prepared access to the underlying information– much of it is thought about private. However, much of this data will be in the source database currently; you just might require authorization to gain access to it.

In its simplest form, revenue equals the amount of earnings left after all costs are paid. That includes salaries, shipping, production, purchasing and so on. The easy formula:

Finest service software application

Profit = Sales − Costs

is relevant just when Expenses includes all expenses. If you desire a portion, also known as the profit margin, you ‘d utilize this formula rather:

(Sales − Expenditures)/ Expenditures

As a simple example, if a little business reports $250,000 in sales and expenditures of $200,000, they have a revenue of $50,000, or a revenue margin of 25%.

With that background details in mind, let’s analyze Adventure Works, our demonstration file, for existing profit information.

How to assess data for profit margin calculations

You’ll start by inspecting the available information in the underlying table(s). Our sample data currently has a calculated column that evaluates revenue and expenditures, so let’s check out that expression initially. Figure A shows a table visual to keep things basic. The calculated column, Revenue Quantity, uses the following DAX expression:

Revenue Quantity = Sales [Sales Amount] − Sales [Total Product Cost]

Figure A

an expression revealing the overall profit of the table's data. The calculated column, Earnings Amount, returns the general revenue of$ 12.5 million dollars. The raw profit worth is offered in the underlying data, so all you need to do is include it in a visual. As a computed column, this worth is offered in the model, so updates are vibrant. The calculated column has all

of the same advantages as a routine column. Here’s the standard guideline: Power BI uses a calculated column expression to all rows in the table however evaluates only worths within the very same row. There’s no aggregating function; Power BI includes the resulting values to the design and calculates it before a filter is engaged.

When everything is so neat and neat, you remain in luck! As you can see in Figure B, the Sales table in the Information window stores a great deal of details. In truth, it has whatever you need except an earnings margin value.

Figure B

Sales table in the Data windows. View the Sales table in the Information windows. What’s not quite clear, but is necessary to know, is that the expression is DAX, a formula expression language used in Analysis Providers, Power BI and Power Pivot in Excel. This language includes functions, operators and worths

. Now, let’s add a calculated column that returns the profit margin.

How to return the revenue margin using a calculated column

Let’s have a look at the very first record in the Sales table (Figure B):

  • The overall expenses are greater than the income.
  • This order comes with a loss of $33.83.

We don’t need to do a thing due to the fact that the computed column, Earnings Amount, is currently readily available in the model. Nevertheless, what we do not see is a profit margin, so let’s add a calculated column to the Sales table to return the revenue margin.

To do this, go back to the Report window, and build a new table visual on the Sales table; consist of only the Earnings Quantity and Sales Amount columns from the Sales table and Sales Order from the Sales Order table. This last field isn’t technically required, but we wish to see the profit margin for each order instead of an aggregate return based on all orders.

To make this most efficient, we’re adjusting a bit to the existing data. Because the earnings amount already exists, we do not need the full formula talked about at the start of this post. We can rather drop the very first subtraction expression and recommendation the Revenue Amount column:


The disadvantage of utilizing this simpler formula is the dependency on the Earnings Amount calculated column. Ought to somebody eliminate that determined column or make modifications to it, the new revenue margin column will return an error.

I want to worry how important it is for Power BI designers to be acquainted with the data. There’s no replacement in scenarios such as this. If you don’t take the time to review existing information, you may repeat what’s currently offered, which can lead to a convoluted mess down the line.

Add a calculated column to return earnings margin as a percentage

To include a calculated column that will return the profit margin as a percentage number, take the following steps:

  1. Select the table visual.
  2. Click the Table Tools tab.
  3. Click New Column.
  4. In the formula bar, enter the following expression (Figure C): % Profit Margin = DIVIDE( [Profit Amount], [Sales Amount].

Figure C

an expression put in Power BI to return a profit margin result for the table. Enter the profit margin expression as a brand-new calculated column. As you can see, Power BI adds the calculated column, %Profit Margin, to the Sales table. With the table visual still selected, examine% Profit Margin in the Fields pane to include this column The Visualization Fields menu open in Power BI with % Profit Margin checkedto the visual(Figure D). Figure D The calculated column returns the revenue margin, a percentage, for each sale. This newly computed column shows the profit margin for each order; that’s why the visual consists of the Sales Order column from the Sales Order table. You can change that column to any other related column that returns earnings margin in a meaningful method.

Extra resources

Using a calculated field makes sense when you desire the profit margin to be part of the design. In some circumstances, you may choose steps. In a future post, I’ll reveal you how to utilize measures to attain the very same worths.

SEE: Hiring Kit: Database engineer (TechRepublic Premium)

This present tutorial depend upon prior knowledge of DAX and determined columns. If you’re not familiar with DAX, consider checking out How to deal with DAX fundamentals in Microsoft Power BI before overcoming this tutorial. In addition, you might wish to read How to add a calculated column in Microsoft Power BI if you’ve never ever dealt with them before.

Check out next: Finest company intelligence tools (TechRepublic)


Leave a Reply

Your email address will not be published. Required fields are marked *