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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
n5722
Helper I
Helper I

Average or relative weeks

Hello,

 

I am looking for a way to stabilise the rate fluctuations on the graph (see pic below).

As you can see the graph shows rates for the past 12 weeks (purple line). I am using relative weeks in my date helper to visualise this so in my filter I have set to show relative weeks from -1, -2, -3 all up to -12.

 

Screenshot 2021-06-23 at 16.19.33.png

 

In order to "stabilise" the rates so that there is not this much fluctuation, I would like to average the rates.

This means that for week 24 I would like to show a number that's the average of the past 12 weeks (week 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14 and 13).
For week 23 I would like to show the average of week 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13 and 12.

For week 22 and the rest of the weeks the same pattern as above...

 

Now, since I am completely clueless about how to do this, I would like to ask you for your help and advice.

 

Thank you!

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @n5722 ,

 

Please try to create a measure like below:

Measure = 
var current_week = SELECTEDVALUE(Sheet3[week])
return 
CALCULATE(
    AVERAGE(Sheet3[rates]),
    FILTER(ALL(Sheet3),
        Sheet3[week]>=current_week-12&&
        Sheet3[week]<=current_week))

 

 

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

View solution in original post

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @n5722 ,

 

Please try to create a measure like below:

Measure = 
var current_week = SELECTEDVALUE(Sheet3[week])
return 
CALCULATE(
    AVERAGE(Sheet3[rates]),
    FILTER(ALL(Sheet3),
        Sheet3[week]>=current_week-12&&
        Sheet3[week]<=current_week))

 

 

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

@V-lianl-msft Thank you very much for this! It worked like a charm 😁

amitchandak
Super User
Super User

@n5722 , Try a measure like

 

Last 12 weeks = CALCULATE(averageX(values('Date'[Week]), [Actual]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-12 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

 

 

These column in date table

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak. Thank you very much for your reply but unfortunately, this did not work out for me.

 

Maybe it might help if I attach the date helper table overview for your convenience.

Here is an overview of it.

 

Screenshot 2021-06-24 at 09.04.53.png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.