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

Wrong average calculation

Hi 

 

I created a matrix table for to calculate the average of my data by each category. Below is the montly expense data I have, classified by "abnormal" and "normal" expenses. I think the averages of "Abnormal" that the matrix calculated are odd because the averages I calculated in Excel for each year are 2018: $209.45, 2019: $700.80, 2020: $529.25. I used the same approach to calcualte the average monthly expense for each year for "Normal" in Excel and got the same result as the matrix. So I don't understand why there is a difference when calculating for "Abnormal". Also, I expect the total of all the averages should be the total monthly average of all 21 months listed here at $2,130.21. How is the matrix calculating the averages? Please help, thanks!

Averageq.JPG

 

YearMonthMonthNoAbnormalMonthly Total
2018August8Abnormal345.40
2018August8Normal1,212.56
2018September9Abnormal180.00
2018September9Normal1,300.74
2018October10Abnormal227.45
2018October10Normal1,729.37
2018November11Normal1,859.07
2018December12Abnormal294.40
2018December12Normal1,326.64
2019January1Normal1,120.02
2019February2Abnormal971.50
2019February2Normal924.73
2019March3Abnormal572.14
2019March3Normal1,907.97
2019April4Abnormal2,397.20
2019April4Normal2,294.14
2019May5Abnormal725.00
2019May5Normal1,946.88
2019June6Abnormal178.97
2019June6Normal1,744.59
2019July7Abnormal409.37
2019July7Normal1,761.31
2019August8Abnormal579.00
2019August8Normal1,672.41
2019September9Abnormal1,025.83
2019September9Normal1,750.29
2019October10Abnormal129.00
2019October10Normal1,517.06
2019November11Abnormal264.61
2019November11Normal2,028.08
2019December12Abnormal1,157.04
2019December12Normal1,440.11
2020January1Abnormal1,489.07
2020January1Normal1,525.59
2020February2Abnormal189.49
2020February2Normal1,648.56
2020March3Abnormal287.71
2020March3Normal2,197.89
2020April4Abnormal150.71
2020April4Normal252.58
2 REPLIES 2
v-zhenbw-msft
Community Support
Community Support

Hi @wsspglobal ,

 

We can use the following measure to calculate the total of each row and column. You can refer it.

 

average total = 
IF (
    ISINSCOPE ( 'Table'[Abnormal] ),
    SUMX (
        VALUES ( 'Table'[Year] ),
        CALCULATE ( AVERAGE ( 'Table'[Monthly Total] ) )
    ),
    SUMX (
        VALUES ( 'Table'[Abnormal] ),
        CALCULATE ( AVERAGE ( 'Table'[Monthly Total] ) )
    )
)

 

The result like this,

 

average 1.jpg

 

If it doesn’t meet your requirement, could you please show us the exact expected result based on the table that we have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HotChilli
Super User
Super User

Do you have rows with zero values in the Excel file that are not shown in the data provided?

Let's look at (2018 Abnormal) data provided:-

180 + 227.45 + 294.4 + 345.4 = 1,047.25

 

There are 4 entries and average shown in the matrix is 261.81. (1047.25 divided by 4)

 

If we take the average you give from excel (209.45) and divide the total above (1047.25), we get a nice round 5. So it suggests there's another row somewhere.

I haven't looked at the other years but it might be similar.

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.