Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi Team,
Please refer the below data and refer the below questions
Required DAX measuere for below questions
1. Compare sales in previous months
2.how much percentage increased/decreased month on month basis on the sales
Thanks
Solved! Go to Solution.
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Sales: =
SUM( sales[sales] )
OFFSET function (DAX) - DAX | Microsoft Learn
Previous month sales: =
CALCULATE (
[Sales:],
OFFSET (
-1,
ALL ( 'calendar'[Month-Year], 'calendar'[Year-Month sort] ),
ORDERBY ( 'calendar'[Year-Month sort], ASC )
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question.
Hi @Anonymous
To help you with the DAX measures for comparing sales in previous months and calculating the percentage increase/decrease in sales month-over-month, I'll break down each question and provide the corresponding DAX expressions.
To compare the sales in the current month with the previous month, we need to calculate the total sales for both the current month and the previous month.
Assuming you have a Sales table with a SalesAmount column, and the Date table is linked properly to your Sales table, you can use the following measure to calculate sales for the previous month:
DAX
Sales Previous Month =
CALCULATE(
SUM(Sales[SalesAmount]),
PREVIOUSMONTH(Dim_Calendar[Date])
)
If you want to show the sales for the current month as well (if not already available), you can simply use this measure:
DAX
Sales Current Month =
SUM(Sales[SalesAmount])
To calculate the percentage change in sales month-over-month (MoM), you can use the following measure:
DAX
Percentage Change in Sales =
VAR CurrentSales = SUM(Sales[SalesAmount])
VAR PreviousSales =
CALCULATE(
SUM(Sales[SalesAmount]),
PREVIOUSMONTH(Dim_Calendar[Date])
)
RETURN
IF(
NOT(ISBLANK(PreviousSales)),
(CurrentSales - PreviousSales) / PreviousSales,
BLANK()
)
Explanation:
DAX
Percentage Change in Sales =
VAR CurrentSales = SUM(Sales[SalesAmount])
VAR PreviousSales =
CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSMONTH(Dim_Calendar[Date]))
RETURN
IF(NOT(ISBLANK(PreviousSales)), (CurrentSales - PreviousSales) / PreviousSales, BLANK())
This should provide you with a way to compare sales across months and calculate the percentage change month on month. Let me know if you need any further adjustments!
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Sales: =
SUM( sales[sales] )
OFFSET function (DAX) - DAX | Microsoft Learn
Previous month sales: =
CALCULATE (
[Sales:],
OFFSET (
-1,
ALL ( 'calendar'[Month-Year], 'calendar'[Year-Month sort] ),
ORDERBY ( 'calendar'[Year-Month sort], ASC )
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question.
hello @Anonymous
please check if this accomodate your need.
1. create measure for your 1st query with following DAX
Query 1 =
var _Month = SELECTEDVALUE('Table'[Month])
Return
SUM('Table'[Sales])
2. create measure for your 2st query with following DAX
Query 2 =
var _PreviousMonth = CALCULATE([Query 1],'Table'[Month]<MAX('Table'[Month]))
var _CurrentMonth = CALCULATE([Query 1],'Table'[Month]=MAX('Table'[Month]))
Return
DIVIDE(
_CurrentMonth,
_PreviousMonth
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
11 | |
10 | |
10 | |
9 |
User | Count |
---|---|
18 | |
13 | |
12 | |
11 | |
8 |