Learn how to calculate and compare sales data for the current and previous month in Power BI.
This exercise covers creating measures for both Current Month Sales and Previous Month Sales, and displaying the comparison in a chart for easy analysis.
Tasks:
- Create a measure to calculate Current Month Sales.
- Create a measure for Previous Month Sales.
- Display both in a comparison chart.
Solution:
Load the below dataset into Power BI-
Sales Dataset
| Date | SalesAmount |
| 01-01-2024 | 10000 |
| 02-01-2024 | 50000 |
| 01-02-2024 | 30000 |
| 01-03-2024 | 25000 |
| 01-04-2024 | 28000 |
| 01-05-2024 | 32000 |
| 01-06-2024 | 35000 |
| 01-07-2024 | 37000 |
| 01-08-2024 | 39000 |
| 01-09-2024 | 41000 |
| 01-10-2024 | 43000 |
| 01-11-2024 | 45000 |
| 01-12-2024 | 47000 |
Create a measure to calculate Current Month Sales-
Now, right-click on the Sales dataset, click on 'New Measure', and write the DAX code below.
Current Month Sales = CALCULATE( SUM(Sales[SalesAmount]), FILTER(Sales, MONTH(Sales[Date]) = MONTH(TODAY())) )
Create a measure for Previous Month Sales-
Now, right-click on the Sales dataset, click on 'New Measure', and write the DAX code below.
Previous Month Sales = CALCULATE( SUM(Sales[SalesAmount]), PREVIOUSMONTH(Sales[Date]) )
Display both in a comparison chart-
Add a clustered column chart to the report page. Drag the Date column to the X-axis and drag both measures to the Y-axis.

As you can see, the chart above is showing the results as expected.
Note: To view the current month’s sales data, ensure that the dataset contains records for the current month’s sales.
I hope you enjoyed this Power BI exercise.
![]()
The DAX code for Previous Month Sales didn’t work for me, and it didn’t return any value