Forum Discussion

richardburling's avatar
1 year ago

Exponential Weighted Moving Average without Time Intelligence

Good Morning,

 

I hope you are all well. 😁

 

I have been trying to calculate you a Exponential Weighted Moving Average based on sales data, but unfortunately I dont have calendar date in my data as its based on Financial Year (FY) and Week No. The request from a client is to be able to have the EWMA reported by Week No but can bridge FY based on a the selections made using slicers. The week number ranges from 1 to 52 for every FY. 

 

The sales data is in a seperate table to both the FY and Week No, these are joined by a key and the data is refreshed on a weekly basis. There is also a column called Week Offset, this start at the latest week and is marked as 0, the reason for this is that the Calendar table is extracting data from a database that has future dates so this may need to be used as I cant have data showing before the latest week.

 

I am unable to attach a spreadsheet but here is an exmaple. 

Any help or guidance on this would be appreciated. 

Financial YearWeek NumberWeek OffsetSales (£)
2023-2443-33536511
2023-2444-32566096
2023-2445-31608640
2023-2446-30490213
2023-2447-29543834
2023-2448-28500859
2023-2449-27575474
2023-2450-26361348
2023-2451-25480139
2023-2452-24545687
2024-251-23461591
2024-252-22601092
2024-253-21541020
2024-254-20435140
2024-255-19234882
2024-256-18222291
2024-257-17386150
2024-258-16321166
2024-259-15439572
2024-2510-14313679
2024-2511-13389012
2024-2512-12493415
2024-2513-11461943
2024-2514-10432882
2024-2515-9456854
2024-2516-8446320
2024-2517-7396670
2024-2518-6518345
2024-2519-5451277
2024-2520-4523998
2024-2521-3511155
2024-2522-2423883
2024-2523-1302786
2024-25240158644

Thanks RB.

 

9 Replies

  • Hi richardburling 

     

    Not everyone is familiar with EWMA. Please provide expected result from the sample data and the reasoning behind.

    • richardburling's avatar
      richardburling
      Helper I

      Hi danextian, thanks for taking the time to response. I have provided an update version of the table with the EWMA added. The first value, highlighted in red, is the simple average of the previous 52 weeks. The excel EWMA formula that I was provided and asked to replicate in Power BI is =(sales*alpha)+((1-alpha)*Previous EWMA). The alpha is set to 0.1 but this will like need to be dynamic or changeable on a filter. 

       

      Financial YearWeek NumberWeek OffsetSales (£)EWMA
      2023-241-75494718443799
      2023-242-74385830438002
      2023-243-73588634453065
      2023-244-72443846452143
      2023-245-71493271456256
      2023-246-70394481450078
      2023-247-69407996445870
      2023-248-68369682438251
      2023-249-67680507462477
      2023-2410-66315483447777
      2023-2411-65356677438667
      2023-2412-64415639436365
      2023-2413-63622488454977
      2023-2414-62386950448174
      2023-2415-61360596439416
      2023-2416-60486936444168
      2023-2417-59468579446609
      2023-2418-58615847463533
      2023-2419-57450311462211
      2023-2420-56365655452555
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi richardburling 

         

        Thanks for reaching out to the Microsoft Fabric Community Forum

         

        In response to your query, here is the DAX formula:

         

        EWMA = 
        VAR PreviousEWMA =
            CALCULATE(
                MAX(Sales_data[Sales]),
                FILTER(Sales_data, Sales_data[Week Offset] = EARLIER(Sales_data[Week Offset]) - 1)
            )
        RETURN
        IF(
            ISBLANK(PreviousEWMA),
            (Sales_data[Sales] * 0.1) + ((1 - 0.1) * 494718),
            (Sales_data[Sales] * 0.1) + ((1 - 0.1) * PreviousEWMA)
        )

         

        Here is the sample output for your review.

        If this post meets your requirements, please consider giving us Kudos. Should you need further assistance, kindly provide more details about your scenario and attach a sample Pbix file.

        If this post was helpful, please consider marking Accept as solution to assist other members in finding it more easily.

        Thanks,
        Pavan

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  richardburling 

    I wanted to follow up, We hope your issue has been resolved.
    If the community member's answer your query, please mark it as "Accept as Answer" and select "Yes" if it was helpful.

    If you need any further assistance, feel free to reach out.

    Thank you,
    Pavan.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi richardburling,

    I wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.
    If the community member's answer your query, please mark it as "Accept as Solution" and select "Yes" if it was helpful.
    If you need any further assistance, feel free to reach out.

    Thank you,
    Pavan.