Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Having trouble plotting a moving average

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. ...
  • v-jiascu-msft's avatar
    7 years ago

    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