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
Kashuo
Helper I
Helper I

How to calculate an average of sums

Hello,

 

I have multiple buildings. Each building has multiple offices. Each office contains desks.

 

Each row of my table is an office. Each office has a desk count. The desk counts for each office range from 1 desk to over 200. I have created a set of groups to put segmented ranges of offices into buckets according to their desk count. Here are the buckets:

2017-02-22 13_56_03-.png

 

 

When I create a bar chart to visualize numbers of offices with various desk counts, I get this:

 

2017-02-22 13_58_17-Proforma comps prototype - Power BI Desktop.png

 

That chart show that the building in question has 41 ofices with either 1 or 2 desks in them, 76 offices with 3 or 4 desks in them, and so on. Here's a second building:

 

 

2017-02-22 14_00_34-Proforma comps prototype - Power BI Desktop.png

This building has a different breakdown. It has 93 offices with 1 or 2 desks, 318 offices with 3 or 4 desks, and so on. When I select to include both buildings, it sums up the desk count totals so that I get this:

2017-02-22 14_03_29-Proforma comps prototype - Power BI Desktop.png

As you can see, it gives me the total desk count as a sum. This is not what I want, though, I want an average. However, when I change the drop down on the Value from Sum to Average, I don't get 67 and 159 and so on (the average of the total desk count for that room type per building)). I get the average of the individual desk counts themselves, like this:

2017-02-22 14_07_15-Proforma comps prototype - Power BI Desktop.png

I've tried using some DAX formulas to try to get the initial SUM per building to stick, and then divide that by number of rows, but it just keep reverting to the individual desk count. It seems like I want to use the "Don't Summarize" option but it's not available.

 

Any ideas? Thanks!!

1 ACCEPTED SOLUTION

Assuming you have all your data in one table, the formula should look like this:

Measure =
       DIVIDE( SUM(YourTable[NrOfDesks])
          , DISTINCTCOUNT( YourTable[YourBuldingIdentifier])
       )

 

DIVIDE is juste a safe division (handles division by 0).

 

DISTINCTCOUNT( YourTable[YourBuldingIdentifier] ) will return the (distinct) number of buildings. This assumes you have one column in your table identifying each building.

View solution in original post

12 REPLIES 12

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.