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
ELW
Advocate II
Advocate II

Take average of rows of table using Sum

Is it possible to have the total in a table average the values when sum aggregation is used?

 

I have a table basically showing share of sales (%) by company.  I'm using Sum aggregation and displaying the value as a percent of the grand total.  In the underlying data, there are multiple records per company that need to be totalled.  I'm also using a Top N filter, if that's relevant.  My question is, can I change the total row to take the average of the % share for each line?  

 

For example, the underlying data looks like this:

CompanySales
A10
A15
A20
B25
B30
C35
C40
C45
C50
D5
D10
E15

 

And the table I have would look like this:

CompanyShare
A15%
B18%
C57%
Average30%

 

The total by default shows 100% since it's showing the percent of the grand total, and I want it to show the average of each line.  In this case 30% = average(15%,18%,57%).

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my solution file from here.

Hope this helps.

Untitled.png


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

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@ELW , Try like

averageX(summarize(Table, Table[company], "_1",SUM ( Table[Sales] ),"_2", CALCULATE(SUM(]Sales[Sales]),ALL(Sales))),[_1])
Ashish_Mathur
Super User
Super User

Hi,

You may download my solution file from here.

Hope this helps.

Untitled.png


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

@Ashish_Mathur That worked perfectly!  Thank you so much!

You are welcome.


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

Please try this expression in a measure to get your desired result in a table visual with the Company column.

 

Avg =
VAR __overalltotal =
    CALCULATE ( SUM ( Sales[Sales] ), ALL ( Sales ) )
RETURN
    AVERAGEX (
        VALUES ( Sales[Company] ),
        CALCULATE ( SUM ( Sales[Sales] ) ) / __overalltotal
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.