Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I have a table where each row represents one case (a technical support case).
The table has the following form.
I have created a figure that shows the number of cases per week for many weeks.
To do this, I created a measure CaseCount
CaseCount = COUNTA(MY_TABLE[CASENUMBER])
and plotted it against a measure WeekNumber
WeekNumber = WEEKNUM(TABLE[CREATEDDATE].[Date],2)
This works as expected.
I'd like to simultaneously plot a smoothed version of this curve, such as a moving average. So I created another measure that is intended to represent a 2-week moving average.
MovAvg = CALCULATE(
COUNTA( MY_TABLE[CASENUMBER] ),
DATESINPERIOD( MY_TABLE[CREATEDDATE].[Date], MAX(MY_TABLE[CREATEDDATE]), -14, DAY )
) / 2
The problem is that I can't seem to get the moving average to work. This is the result that I currently have when I add my moving average curve to the figure.
I'm having trouble understanding why the result is incorrect. Does anyone know what may have gone wrong, or whether there is a better way to do something like this?
Thanks.
Solved! Go to Solution.
Hi @Anonymous,
It's always a good idea to create a Date table for the Time Intelligence functions. Because the fact table could have discontinuous dates, the MAX(MY_TABLE[CREATEDDATE]) may not the end of a week.
1. Create a Date table.
Calendar = ADDCOLUMNS(CALENDARAUTO(), "WeekNum", WEEKNUM([Date], 2)
2. Establish a relationship.
3. The measure could be like below.
MovAvg = CALCULATE ( COUNTA ( MY_TABLE[CASENUMBER] ), DATESINPERIOD ( calendar[DATE], MAX ( calendar[DATE] ), -14, DAY ) ) / 2
Best Regards,
Dale
Hi @Anonymous,
It's always a good idea to create a Date table for the Time Intelligence functions. Because the fact table could have discontinuous dates, the MAX(MY_TABLE[CREATEDDATE]) may not the end of a week.
1. Create a Date table.
Calendar = ADDCOLUMNS(CALENDARAUTO(), "WeekNum", WEEKNUM([Date], 2)
2. Establish a relationship.
3. The measure could be like below.
MovAvg = CALCULATE ( COUNTA ( MY_TABLE[CASENUMBER] ), DATESINPERIOD ( calendar[DATE], MAX ( calendar[DATE] ), -14, DAY ) ) / 2
Best Regards,
Dale
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
85 | |
66 | |
51 | |
45 |
User | Count |
---|---|
216 | |
89 | |
82 | |
66 | |
57 |