Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi,
I have a rolling average measure which works as it should:
Can anyone help with the correct measure, please?
Thanks
James
Solved! Go to Solution.
Hi @James__ ,
According to your description, here are my steps you can follow as a solution.
You can create a measure as below:
Sales R12M =
VAR NumOfMonths = 12
VAR LastCurrentDate =
MAX ( 'Date'[Date] )
VAR Period =
DATESINPERIOD ( 'Date'[Date], LastCurrentDate, - NumOfMonths, MONTH )
VAR Result =
CALCULATE (
AVERAGEX (
VALUES ( 'Date'[YearMonth]),
[Sales Amount]
),
Period
)
VAR FirstDateInPeriod = MINX ( Period, 'Date'[Date] )
VAR LastDateWithSales = MAX ( Sales[Order Date] )
RETURN
IF ( FirstDateInPeriod <= LastDateWithSales, Result )
Then the result is as follows.
You can refer to the following documents that may be helpful to you:
Rolling 12 Months Average in DAX - SQLBI
Solved: Rolling 12M Average only calculate average on year... - Microsoft Power BI Community
Cumulative rolling average by day/month - Microsoft Power BI Community
Solved: Need help with rolling periods past 12M, 6M, P3M a... - Microsoft Power BI Community
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @James__ ,
According to your description, here are my steps you can follow as a solution.
You can create a measure as below:
Sales R12M =
VAR NumOfMonths = 12
VAR LastCurrentDate =
MAX ( 'Date'[Date] )
VAR Period =
DATESINPERIOD ( 'Date'[Date], LastCurrentDate, - NumOfMonths, MONTH )
VAR Result =
CALCULATE (
AVERAGEX (
VALUES ( 'Date'[YearMonth]),
[Sales Amount]
),
Period
)
VAR FirstDateInPeriod = MINX ( Period, 'Date'[Date] )
VAR LastDateWithSales = MAX ( Sales[Order Date] )
RETURN
IF ( FirstDateInPeriod <= LastDateWithSales, Result )
Then the result is as follows.
You can refer to the following documents that may be helpful to you:
Rolling 12 Months Average in DAX - SQLBI
Solved: Rolling 12M Average only calculate average on year... - Microsoft Power BI Community
Cumulative rolling average by day/month - Microsoft Power BI Community
Solved: Need help with rolling periods past 12M, 6M, P3M a... - Microsoft Power BI Community
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
82 | |
81 | |
52 | |
39 | |
35 |
User | Count |
---|---|
95 | |
79 | |
52 | |
49 | |
47 |