Profit Margin

Now it's time to create the Profit Margin calculation (the profit margin is simply profit divided by sales). For this measure, you are going to use the DIVIDE function. The DIVIDE function is recommended over the divide operator (/) because the DIVIDE function automatically handles divide by zero occurrences. In the case of divide by zero occurrences, the DIVIDE function returns blank.

Create a new measure on the Internet Sales table using the following code:

Profit Margin = DIVIDE([Profit], [Total Sales])

Next, set the formatting as a percentage. From the modeling ribbon, click on the % icon, as shown in the following screenshot:

Figure 12-Setting formatting as a percentage

Get Microsoft Power BI Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.