0
0
Power-biHow-ToBeginner ยท 3 min read

How to Calculate Percentage Using DAX in Power BI

To calculate a percentage in Power BI using DAX, create a measure that divides a part value by a total value and multiply by 100. For example, use Percentage = DIVIDE(SUM(Table[Part]), SUM(Table[Total])) * 100 to get the percentage result.
๐Ÿ“

Syntax

The basic syntax to calculate percentage in DAX is:

  • Percentage = DIVIDE(Numerator, Denominator) * 100

Where:

  • Numerator is the part or subset value you want to measure.
  • Denominator is the total or whole value.
  • DIVIDE() safely handles division and avoids errors if the denominator is zero.
  • Multiplying by 100 converts the fraction to a percentage.
DAX
Percentage = DIVIDE(SUM(Table[Part]), SUM(Table[Total])) * 100
๐Ÿ’ป

Example

This example shows how to calculate the percentage of sales for a product category compared to total sales.

DAX
Total Sales = SUM(Sales[Amount])

Category Sales = SUM(Sales[Amount])

Category Sales % = DIVIDE([Category Sales], [Total Sales]) * 100
Output
If Total Sales = 1000 and Category Sales = 250, then Category Sales % = 25
โš ๏ธ

Common Pitfalls

Common mistakes when calculating percentages in DAX include:

  • Not using DIVIDE() and instead using simple division (/), which can cause errors if the denominator is zero.
  • Forgetting to multiply by 100, resulting in a decimal fraction instead of a percentage.
  • Using incorrect aggregation functions, like mixing SUM() and COUNT() inconsistently.
  • Not considering filter context, which can change totals unexpectedly.
DAX
Wrong = SUM(Sales[Amount]) / SUM(Sales[Total])  -- May cause divide by zero error

Right = DIVIDE(SUM(Sales[Amount]), SUM(Sales[Total])) * 100
๐Ÿ“Š

Quick Reference

ConceptDescriptionExample
DIVIDE()Safe division avoiding errors if denominator is zeroDIVIDE(SUM(Table[Part]), SUM(Table[Total]))
Multiplying by 100Converts decimal to percentageDIVIDE(...) * 100
SUM()Aggregates values for numerator or denominatorSUM(Sales[Amount])
Filter ContextAffects totals and percentages dynamicallyUse measures inside visuals
โœ…

Key Takeaways

Use DIVIDE() in DAX to safely calculate percentages and avoid division errors.
Always multiply the division result by 100 to convert to a percentage.
Ensure numerator and denominator use consistent aggregation functions like SUM().
Remember filter context affects your percentage results in reports.
Test your measures with sample data to verify correct percentage output.