Forum Discussion
Sum Of Average
https://docs.google.com/spreadsheets/d/1gUcYOo2iAabmPHrjDgwnLaitmDt_FgdR/edit?usp=sharing&ouid=114539450464449246981&rtpof=true&sd=true
Hi Experts need a help in power bi,
to create a measure for sum of average.
the below avg measure sum needed,
for example for category Beauty it should show 1673(791.13+800.72+821.31) and Home its should show 2455.
For reference the excel file of demodata has been attached.
4 Replies
- Nathaniel_CCommunity Champion
Hi Nobie ,
If I understand your question, please try this:Average Per Category = var _category = MAX(Prod[Category]) var _calc = CALCULATE(AVERAGEX(Prod,Prod[Price]*Prod[Quantity]),FILTER(ALL(Prod),Prod[Category]=_category)) return _calcOn your measure for average, isn't that the total?
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πare nice too.
Nathaniel- Nathaniel_CCommunity Champion
Hi Nobie ,
If you want to only place that value 1x for each category, you might wish to try this:Average Per Category Clean = var _category = MAX(Prod[Category]) var _product = MAX(Prod[Product]) var _calc = CALCULATE(AVERAGEX(Prod,Prod[Price]*Prod[Quantity]),FILTER(ALL(Prod),Prod[Category]=_category)) var _calcMax = CALCULATE(MAX(Prod[Product]), FILTER(ALL(Prod),Prod[Category]=_category)) return IF(_product = _calcMax,_calc)
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πare nice too.
Nathaniel - NobieHelper II
Hi Nathaniel_C , Thanks for a solution
but this is not the solution I am looking.
U can see your solution is giving me an average for a category but I need the sum of the average.
in place of 804 it should be sum of 791+800+821 =1673.- Nathaniel_CCommunity Champion
Hi Nobie ,
Please try this:Sum of Avg = var _category = MAX(Prod[Category]) Var _product = MAX(Prod[Product]) var _maxProd = CALCULATE(MAX(Prod[Product]), FILTER(ALL(Prod),Prod[Category]= _category)) var _Table = SUMMARIZECOLUMNS(Prod[Category],"zzzz",Sumx(Prod,Prod[Price]*Prod[Quantity])) var _calc = CALCULATE(MAX('Table'[zzzz]),'Table'[Category]=_category) return IF(_maxProd=_product,_calc)
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πare nice too.
Nathaniel