How to Create Month-over-Month (MoM) Calculation in Power BI Using DAX
To create a Month-over-Month (MoM) calculation in Power BI, use the
CALCULATE function combined with DATEADD to shift the date context by one month. A common DAX formula is: MoM Growth = DIVIDE(SUM(Sales[Amount]) - CALCULATE(SUM(Sales[Amount]), DATEADD(Calendar[Date], -1, MONTH)), CALCULATE(SUM(Sales[Amount]), DATEADD(Calendar[Date], -1, MONTH))), which calculates the percentage change from the previous month.Syntax
The basic syntax for a Month-over-Month (MoM) calculation in DAX uses these functions:
- CALCULATE(): Changes the filter context to calculate values for a specific period.
- DATEADD(): Shifts the date by a specified number of intervals (e.g., months).
- SUM(): Aggregates the numeric column, like sales amount.
- DIVIDE(): Safely divides two numbers and handles division by zero.
Example syntax:
DAX
MoM Growth = DIVIDE(
SUM(Sales[Amount]) - CALCULATE(SUM(Sales[Amount]), DATEADD(Calendar[Date], -1, MONTH)),
CALCULATE(SUM(Sales[Amount]), DATEADD(Calendar[Date], -1, MONTH))
)Example
This example calculates the Month-over-Month growth percentage for sales amount. It compares the current month's sales to the previous month's sales and shows the growth rate.
DAX
MoM Growth = DIVIDE(
SUM(Sales[Amount]) - CALCULATE(SUM(Sales[Amount]), DATEADD(Calendar[Date], -1, MONTH)),
CALCULATE(SUM(Sales[Amount]), DATEADD(Calendar[Date], -1, MONTH))
) * 100Output
If current month sales = 1200 and previous month sales = 1000, MoM Growth = ((1200 - 1000) / 1000) * 100 = 20%
Common Pitfalls
Common mistakes when creating MoM calculations include:
- Not having a proper continuous date table marked as a date table in Power BI.
- Using
PREVIOUSMONTH()without a proper date context, which can return blank results. - Forgetting to multiply by 100 to convert the ratio to a percentage.
- Not handling division by zero, which
DIVIDE()safely manages.
Wrong approach example:
DAX
MoM Growth Wrong = (SUM(Sales[Amount]) - SUM(Sales[Amount])) / SUM(Sales[Amount])
Output
Always returns 0 because it compares the same value without shifting date context.
Quick Reference
| Function | Purpose | Example Usage |
|---|---|---|
| CALCULATE() | Changes filter context | CALCULATE(SUM(Sales[Amount]), DATEADD(...)) |
| DATEADD() | Shifts dates by interval | DATEADD(Calendar[Date], -1, MONTH) |
| SUM() | Aggregates values | SUM(Sales[Amount]) |
| DIVIDE() | Safe division | DIVIDE(numerator, denominator) |
Key Takeaways
Use CALCULATE with DATEADD to shift the date context by one month for MoM calculations.
Always use DIVIDE to avoid errors from division by zero.
Ensure you have a continuous date table marked as a date table in Power BI.
Multiply the result by 100 to express MoM growth as a percentage.
Avoid comparing values without shifting the date context, which leads to incorrect results.