How to Calculate Percentage in Power BI using Measure
In Power BI, you can calculate percentages using measures. Measures are calculations that you define in Power BI to perform calculations on your data. Here’s an example of how to calculate a percentage using a measure:
Step 1: Create a Measure
To calculate a percentage, you need to create a measure that performs the necessary calculation. Let’s say you have a Sales table with columns “Revenue” and “Total Sales”. You want to calculate the percentage of Revenue out of Total Sales. Follow these steps to create a measure:
Sales Percentage = DIVIDE(SUM(Sales[Revenue]), SUM(Sales[Total Sales]))
In the above measure, the DIVIDE function is used to divide the sum of Revenue by the sum of Total Sales. This will give you the percentage value.
Step 2: Format the Measure
By default, the measure will be displayed as a decimal number. To format it as a percentage, you can use the FORMAT function. Here’s an example of how to format the Sales Percentage measure:
Sales Percentage = FORMAT(DIVIDE(SUM(Sales[Revenue]), SUM(Sales[Total Sales])), "0%")
In the above measure, the “0%” format is used to display the result as a percentage with 0 decimal places.
Step 3: Use the Measure in Visualizations
Once you have created and formatted the measure, you can use it in your visualizations. For example, you can create a table or a chart and include the Sales Percentage measure as a column or a data point. This will show the percentage value based on your calculation.
Example
Let’s illustrate the above steps with an example. Assume we have the following data in the Sales table:
Revenue | Total Sales |
---|---|
500 | 1000 |
750 | 1500 |
1000 | 2000 |
Using the Sales Percentage measure, we can calculate the percentage of Revenue out of Total Sales as follows:
Sales Percentage = DIVIDE(SUM(Sales[Revenue]), SUM(Sales[Total Sales]))
Applying the measure to the above data, we get the following result:
Revenue | Total Sales | Sales Percentage |
---|---|---|
500 | 1000 | 50% |
750 | 1500 | 50% |
1000 | 2000 | 50% |