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.
I have set up measures to get the percentage of total foreign sales over total gross income for 2007 - 2013. However, I do not know how to set up the weighted averages. Below are examples of my questions and weighted averages. These weighted averages need to be in the same dashboard. Thank you for your help.
2007 86%
2008 87%
2009 89%
2010 90%
2011 91%
2012 92%
2013 88%
Weighted average 1 = (2007+2008+2009)/(2007+2008+2009)
Weighted average 2 = (2008+2009+2010)/(2008+2009+2010)
Weighted average 3 = [(2009+2010)/(2009+2010)]*2/3 + [2011/2011]*1/3
Weighted average 4 = [2011/2011]*1/3 + [(2012+2013)/(2012+2013)]*2/3
Solved! Go to Solution.
Hi, @minhquankhong
It’s my pleasure to answer for you.
According to your description,I think you can create four measures to calculate the desired result.
Like this:
weighted average4 = var a=CALCULATE('Measures 1'[% of AFBI/Total Income],'PL_Domestic Entitiies'[Year]="2011")
var aa=CALCULATE('Measures 1'[Total AFBI],'PL_Domestic Entitiies'[Year]="2011")
var b=CALCULATE('Measures 1'[% of AFBI/Total Income],'PL_Domestic Entitiies'[Year]="2012")
var bb=CALCULATE('Measures 1'[Total AFBI],'PL_Domestic Entitiies'[Year]="2012")
var c=CALCULATE('Measures 1'[% of AFBI/Total Income],'PL_Domestic Entitiies'[Year]="2013")
var cc=CALCULATE('Measures 1'[Total AFBI],'PL_Domestic Entitiies'[Year]="2013")
return DIVIDE(c*cc+b*bb,c+b)*DIVIDE(2,3)+DIVIDE(a*aa,a)*DIVIDE(1,3)
Here is my sample .pbix file.Hope it helps.
If it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @minhquankhong
It’s my pleasure to answer for you.
According to your description,I think you can create four measures to calculate the desired result.
Like this:
weighted average4 = var a=CALCULATE('Measures 1'[% of AFBI/Total Income],'PL_Domestic Entitiies'[Year]="2011")
var aa=CALCULATE('Measures 1'[Total AFBI],'PL_Domestic Entitiies'[Year]="2011")
var b=CALCULATE('Measures 1'[% of AFBI/Total Income],'PL_Domestic Entitiies'[Year]="2012")
var bb=CALCULATE('Measures 1'[Total AFBI],'PL_Domestic Entitiies'[Year]="2012")
var c=CALCULATE('Measures 1'[% of AFBI/Total Income],'PL_Domestic Entitiies'[Year]="2013")
var cc=CALCULATE('Measures 1'[Total AFBI],'PL_Domestic Entitiies'[Year]="2013")
return DIVIDE(c*cc+b*bb,c+b)*DIVIDE(2,3)+DIVIDE(a*aa,a)*DIVIDE(1,3)
Here is my sample .pbix file.Hope it helps.
If it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Janey,
Sorry for the late reply. I was out of the office last week and in training the whole time this week. I tested your solution. It worked. Thank you so much for your help.
@minhquankhong , the same data does seem to be inline with what you are asking
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
96 | |
94 | |
80 | |
71 | |
64 |
User | Count |
---|---|
115 | |
106 | |
96 | |
81 | |
72 |