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

Pivottable % of parent row running weighted average

Hi, 

I have a pivot table with % of parent row total calculated via Value field settings in the pivottable.

I want to calculate the weighted average of the % of parent row total over different category A and B by: 

1. Calculating the rolling average of % of parent row total for the actual week, the past week, and the coming week, for category A and B. Let's call it result X for category A and result Y for category B

2. Calculating the average of X and Y, where X is given weight 1 and Y weight 0.5

 

Any ideas how that can be done much appreciated! 

 

Capture Running total average.PNG

1 ACCEPTED SOLUTION

Hi @Anonymous 

You can try this measure:

Avg of A and B = DIVIDE([Rolling Avg A]*1+[Rolling Avg B]*0.5,1.5)

Result is as below.

Week 21 return to (5*1 + 1*0.5)/(1.5) =3.67.

1.png

 

Best Regards,

Rico Zhou

 

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
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

From your post, I think you wan to calculate the rolling average for actual week, the past week, and the coming week(3 weeks)

Due to I don't know your data source, I build a sample to have a test.

My Sample:

1.png

My measure:

 

Rolling Avg A = AVERAGEX(FILTER(ALL('Table'),'Table'[WeekNum]<=MAX('Table'[WeekNum])+1&&'Table'[WeekNum]>=MAX('Table'[WeekNum])-1),'Table'[A])
Rolling Avg B = AVERAGEX(FILTER(ALL('Table'),'Table'[WeekNum]<=MAX('Table'[WeekNum])+1&&'Table'[WeekNum]>=MAX('Table'[WeekNum])-1),'Table'[B])

 

Result:

2.png

You see Rolling Avg A in WeekNum = (2+3+10)/3.

I am confused about your require 2. What does "X is given weight 1 and Y weight 0.5" mean?

If this reply still couldn't help you solve your problem, please show more details about your table, your calculate logic to me.

Or you can share your pbix file with me by your Onedrive for Business.

 

Best Regards,

Rico Zhou

 

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

Anonymous
Not applicable

Hi @v-rzhou-msft ,

Perfect that solves the first part of the question.

Sorry for being unclear about the second part, what I mean is that I want the average of A and B for each week, but A is given weight 1 and B is given weight 0.5, for example for week 21 I want (5*1 + 1*0.5)/(1.5) =3.67. Would be great if you have a solution for that! 

Hi @Anonymous 

You can try this measure:

Avg of A and B = DIVIDE([Rolling Avg A]*1+[Rolling Avg B]*0.5,1.5)

Result is as below.

Week 21 return to (5*1 + 1*0.5)/(1.5) =3.67.

1.png

 

Best Regards,

Rico Zhou

 

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

 

Anonymous
Not applicable

Thanks!

Ashish_Mathur
Super User
Super User

Hi,

It's an MS Excel question.  Post it here - Results in Microsoft 365 and Office - Microsoft Community 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi

Ok thanks for redirecting. However, would it be possible to achieve this in PowerBI? 

Hi,

Since you have weeks involved here and weeks spill into following months, I find it difficult to use Date/Time Intelligence functions where weeks are involved.  So I am sure, someone else will be able to help you here. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.