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
Anonymous
Not applicable

Static Average for a period of 8 weeks

Hello,

I am having an issue with creating a DAX measure that would calculate the static "average" of a column(Eg - quantity) for over a period of 8 weeks. I will be using this average value on a line over a bar chart. In my case, the average keeps changing every week, but when I put the avg value in a card it gives me a single value which I want to reproduce in my bar chart. 

 

Would someone help me correcting the below measure that would give me a static average? I even tried including Allexcept(week) but that didn't work. 

 

Avg of last 8 weeks =
CALCULATE(Average(master_detail_new[qty]),FILTER(master_detail_new,master_detail_new[forecast_type]="Actual Processed" ),
DATESBETWEEN(master_detail_new[week],
DATE(2019,12,1),
DATE(2020,2,9)
)
)
 
Thanks!! DAX Query  
1 ACCEPTED SOLUTION

Hi @Anonymous ,

Maybe you could try to create a constant line in the visual, like below.

3.PNG

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
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

7 REPLIES 7
amitchandak
Super User
Super User

Ideally week should come from separate table all should be used on week table

CALCULATE(Average(master_detail_new[qty]),FILTER(master_detail_new,master_detail_new[forecast_type]="Actual Processed" ),
filter(all(master_detail_new),master_detail_new[week]>= DATE(2019,12,1) && master_detail_new[week]<=DATE(2020,2,9)
)
)

 

Or , if selected from UI

measure =
var _max = maxx(master_detail_new,master_detail_new[week])
var _min = _max-56
return
CALCULATE(Average(master_detail_new[qty]),FILTER(master_detail_new,master_detail_new[forecast_type]="Actual Processed" ),
filter(all(master_detail_new),master_detail_new[week]>= DATE(2019,12,1) && master_detail_new[week]<=DATE(2020,2,9)
)
)

Anonymous
Not applicable

Hi @amitchandak ,

 

Thanks for your response. I tried using your measure but, still getting the same rolling average.

Here is a screencast - https://www.screencast.com/t/xzwLoSsxwZ

In the screenshot I actually want it to be a straight line meaning a static average(sum 8 weeks qty/8). Hope this makes sense.

 

Thanks

@Anonymous , share current formula

 if you need more help make me @

Appreciate your Kudos.

Anonymous
Not applicable

@amitchandak , I've used the formula below that you provided. I am hoping this is not an out of the box functionality. 

 

Avg of last 8 weeks =
var _max = maxx(master_detail_new,master_detail_new[week])
var _min = _max-56
return
CALCULATE(Average(master_detail_new[qty]),FILTER(master_detail_new,master_detail_new[forecast_type]="Actual Processed" ),
filter(all(master_detail_new),master_detail_new[week]>= DATE(2019,12,1) && master_detail_new[week]<=DATE(2020,2,9)
)
)
 
Anonymous
Not applicable

Hi Community,

 

Anyone out there who can help me with a solution for this? 

 

Thank you in advance.

Hi @Anonymous ,

Could you tell me if your problem has been solved? If it is, kindly mark the helpful answer as a solution if you feel that makes sense. Welcome to share your own solution. More people will benefit from the thread.

 

Best Regards,

Xue Ding

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

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

Hi @Anonymous ,

Maybe you could try to create a constant line in the visual, like below.

3.PNG

Best Regards,

Xue Ding

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

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

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.