Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

12 Week Rolling Average without Dates

Good morning and Happy New Year, 

 

I have been wracking my brains for a while now on how to solve a problem. What I need to do is create a rolling 12 week average, which I seem to have done but the problem lies with the initial 12 weeks of the selected financial year. Rather then looking back at the 12 weeks in the previous financial year, its start off at week 1 and accumulates the average until it gets to week 12. Hopefully the visual below explains it better. 

 

richardburling_0-1704279739104.png

 

Ideally, not sure if its possible in Power Bi to generate values in years that arent selected in the slicers, but I would want week 1 to be an average of the previous 12 weeks in the last financial year even if its not been selected so the user can select a year at a time rather then multiples. I have put the DAX below. 

 

_12W_RA =
VAR CurrentWeek = MAX(DIM_CALENDAR[WEEK_OFFSET])
RETURN
CALCULATE(
SUMX(
FILTER(
ALLSELECTED(FCT_LCHID),
FCT_LCHID[DIM_CALENDAR.WEEK_OFFSET] <= CurrentWeek
&& FCT_LCHID[DIM_CALENDAR.WEEK_OFFSET] >= CurrentWeek - 11
),
FCT_LCHID[LOST_CUSTOMER_HOURS]
)
)/12

 

Any help would be great. 

Thanks

Rich

 

2 REPLIES 2
v-yifanw-msft
Community Support
Community Support

Hi @richardburling ,

 

Based on the information you provided, for solving the problem that week 1 is the average of the first 12 weeks of the previous fiscal year, you can follow these steps:

1.Add new measure.

 

Measure =

AVERAGEX (

    FILTER (

        ALL ( 'Table' ),

        YEAR ( [Month Year] )

            = YEAR ( SELECTEDVALUE ( 'Table'[Month Year] ) ) - 1

            && 'Table'[Week] <= 12

    ),

    'Table'[amount]

)

 

 

Final output:

vyifanwmsft_0-1704785237906.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi. 

Thank you for your response. 

 

Unfortunatley the DAX doesnt work on my dataset. The client I work for uses a financial year column which is a text data type, for example, 2023-24. They also work on a 52 week year and there isnt a unqiue column in the DIM_Calendar table that combines the Financial_Year and Week_No, like you have done in your data 'WeekNumber & Year".

 

Also, the value that I am looking to create a rolling 12 week average on isnt summed by the Week_No but by an unique record ID. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.