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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
TomStaps
Helper I
Helper I

Calculate average, count same group as 1

Hello everyone,

 

In Power BI I need to make the calculations which you can see below.

 

- I want to know the average from column A, B and C seperate.

- Each company counts as one. Company x has 4 participants, only 2 filled in a score. Then I calculate 3+4=7 --> 7/2=3.5

- In the case of column A it should be: (3.5+4)/2=3.75.

TomStaps_0-1638579040232.png

PowerBI calculate the average from all scores and does not count all answers from 1 company as 1.

 

I hope you understand me and can give a solution how I can put this calculations in Power BI.

 

Thanks in advance for you help.

 

Best Regards,

Tom

 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @TomStaps 

 

Try this code for each column, for instance for column A:

Avr. A =
VAR _A =
    SUMMARIZE( 'Table', 'Table'[Company Name], "Avr.", AVERAGE( 'Table'[A] ) )
RETURN
    AVERAGEX( _A, [Avr.] )

 

Output:

VahidDM_1-1638664551956.png

 

Avr. B = 
VAR _A =
    SUMMARIZE( 'Table', 'Table'[Company Name], "Avr.", AVERAGE( 'Table'[B] ) )
RETURN
    AVERAGEX( _A, [Avr.] )
Avr. C = 
VAR _A =
    SUMMARIZE( 'Table', 'Table'[Company Name], "Avr.", AVERAGE( 'Table'[C] ) )
RETURN
    AVERAGEX( _A, [Avr.] )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

9 REPLIES 9
VahidDM
Super User
Super User

Hi @TomStaps 

 

Try this code for each column, for instance for column A:

Avr. A =
VAR _A =
    SUMMARIZE( 'Table', 'Table'[Company Name], "Avr.", AVERAGE( 'Table'[A] ) )
RETURN
    AVERAGEX( _A, [Avr.] )

 

Output:

VahidDM_1-1638664551956.png

 

Avr. B = 
VAR _A =
    SUMMARIZE( 'Table', 'Table'[Company Name], "Avr.", AVERAGE( 'Table'[B] ) )
RETURN
    AVERAGEX( _A, [Avr.] )
Avr. C = 
VAR _A =
    SUMMARIZE( 'Table', 'Table'[Company Name], "Avr.", AVERAGE( 'Table'[C] ) )
RETURN
    AVERAGEX( _A, [Avr.] )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Hi @VahidDM ,

 

The calculation is right and works. I really appreciate your help. Now I have another problem. As a follow up I need to calculate the weighted average from column A, B and C. So this time not 1 column, but 3. I tried to multiply your formula, but this I am not able to get it. Can you please help?

 

Already thanks for your help.

 

Best Regards,

Tom

Hi @TomStaps 

 

If I understood your request correctly, try this:

Measure = 
Var _A = SELECTCOLUMNS('Table',"Company Name",'Table'[Company Name],"Value",'Table'[A])
Var _B = SELECTCOLUMNS('Table',"Company Name",'Table'[Company Name],"Value",'Table'[B])
Var _C = SELECTCOLUMNS('Table',"Company Name",'Table'[Company Name],"Value",'Table'[C])
Var _D = AVERAGEX(GROUPBY(UNION(_A,_B,_C),[Company Name],"Avr.",AVERAGEX(CURRENTGROUP(),[Value])),[Avr.])
return
_D

 

Output:

VahidDM_0-1638915538693.png

 

 

If my posts helps, please consider accepting them as the solutions to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Hi @VahidDM

 

I used your calculations in Power BI and I think it works. The outcome of A is correct now. Tomorrow night I will try it on more columns to check it. I will let you know if it works. Already, thank you very much for your input! I appreciate it. 

bcdobbs
Community Champion
Community Champion

Would definently unpivot it then. Let me know if you need more detail on that. Happy to help.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
bcdobbs
Community Champion
Community Champion

Try something like:

 

Col A Measure =
AVERAGEX (

      VALUES(Table[CompanyId]),

      AVERAGE(Table[A])
)

 

This iterates over each company in turn and finds their average and then averages the whole lot.

    



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
bcdobbs
Community Champion
Community Champion

What are A, B and C? If they are categories then you could make things simpler by unpivoting the data in power query first so you end up with a data table of:

 

Company, Category, Value


Put Company on rows of matrix, Category on columns of matrix and then a measure similar to above in the values.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

A, B, C are cathegories. 

- The question in the survey was.

 

- How do you rate the following cathegory (for example A)? Give a score between 1 and 5.

Hi Tom,

You could create a calculated table using summarize: 

Filteredtable = SUMMARIZE('Table','Table'[Company],"A",AVERAGE('Table'[A]),"B",AVERAGE('Table'[B]),"C",AVERAGE('Table'[C]))
ValtteriN_0-1638617396735.png

 

Afterwards, you can create measures for the categories:
Average of Category A = AVERAGE(Filteredtable[A]),
Average of Category B = AVERAGE(Filteredtable[B]),
Average of Category C = AVERAGE(Filteredtable[C])

ValtteriN_1-1638617419987.png


By doing this you can use the created measures to for example rate the categories. I am not sure if I understood what you meant with this but perhaps something lik RANKX could be used to categorize the results.





 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.