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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
SamTailor
Helper I
Helper I

Monthly Average Grand Total calculation - Help needed

Hi!

 

I'm new in Power BI and can't figure out how to do a tricky thing with Grand Total of Average

I have a table with Monthly averages, but grand totalin Power BI shows me SUM of these averages.

 

 

 

2.PNG

What i want him to shows me in Grand Total is Year Average basing on number of days.

 This is how i do it in Excel

3.PNG

 

Plese Help, maybe there is some formula to solve this ?

1 ACCEPTED SOLUTION
AlexChen
Microsoft Employee
Microsoft Employee

Hi,

 

In this scenario, if you include “Direction” column into your table visual, definitely your measure will be sliced by “direction”. This is how DAX works. So you need to group on month in your calculation.

 

AverageMeasure = CALCULATE(AVERAGEA(Direction[AV Plan]),ALLEXCEPT(Direction,Direction[Month #]))

 

1.png

 

As to show Year Average basing on number of days in your top table of this case(I assume it’s called “Direction2”), You can create a following measure:

 

avgMeasure = CALCULATE(sumx(Direction2, Direction2[monthDay] * Direction2[Average]) / sumx(Direction2, Direction2[monthDay]))

 

2.png

 

Best Regards

Alex

 

 

 

View solution in original post

11 REPLIES 11
AlexChen
Microsoft Employee
Microsoft Employee

Hi,

 

In this scenario, if you include “Direction” column into your table visual, definitely your measure will be sliced by “direction”. This is how DAX works. So you need to group on month in your calculation.

 

AverageMeasure = CALCULATE(AVERAGEA(Direction[AV Plan]),ALLEXCEPT(Direction,Direction[Month #]))

 

1.png

 

As to show Year Average basing on number of days in your top table of this case(I assume it’s called “Direction2”), You can create a following measure:

 

avgMeasure = CALCULATE(sumx(Direction2, Direction2[monthDay] * Direction2[Average]) / sumx(Direction2, Direction2[monthDay]))

 

2.png

 

Best Regards

Alex

 

 

 

Hi ALex,

 

Thanks for your reply. I still can't make it work the way U do. I created the measure for Direction2 and this is what i got

 

212.PNG

 

 

 

The problem is that Number of days is 186 in my case - Power BI sums it((( How have you created a column "monthDay"? - i believe its the key queestion to solve the problem....

Hi,

 

You can go to powerbi desktop.  choose "monthDay" column.

 

1.png

 

choose "Default Summarization: Do Not Summarize".

 

2.png

 

do the samething for column "month".

 

Now remove your table visual on "Direction2" then create a new one.

 

Best Regards

Alex

 

 

When I do so - it simply removes Grand Totals, the calculation logic is still the same - formula takes SUM of days in each month and it gives me wrong result 11 153. How have you made the formula to calculculate not the sum of days in table but simply nubber of days?

 

123132.PNG

 

Hi Sam,

 

If you have many duplicated records in your Direction2 like below.

 

4.png

You can create another table to remove them.

 

Direction3 = Distinct(Direction2)

 

then create the table visual based on Direction3.

 

Best Regards

Alex

 

Thanks!

 

I created a caclulated table removing all duplicates, created a connection between this table and data and adoped your formula for it. It worked.

Colunn = CALCULATE(sumx('Calc Table Plan';'Calc Table Plan'[NumberDays]) * sum (Plan[AV Plan]))

 

 

Measure = SUM(Plan[Colunn]) / SUMX('Calc Table Plan';'Calc Table Plan'[NumberDays])

 

 

 

I got the result I wanted, now I have rigth grand total calculatiing  and even if I slice it by Directions!

Greg_Deckler
Super User
Super User

Couple things you could do. In your table settings, click the drop down arrow next to "Average Plan" and choose "Average" instead of "Sum".

 

averages.png

 

You could also create a Measure like: 

 

MyAverage = AVERAGE(Averages[Average Plan])

Use that in your table instead.

 

 

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I'm afraid this method gives a little different result - 66 885 instead of 66 920

Correct, this is averaging all of the averages, which will return a different result than taking the SUM total and dividing by the total number of days. Lots of rounding issues going on. I can't figure out why your numbers are different than mine in Excel (see below).

 

So, basically, I'm not sure of your source data, but if you have something like this:

 

MonthDaysAverage
3170425
2960138
3159234
3058987
3158371
3061831
3163388
3163795
3069316
3174747
3078325
3184066

 

Then create a calculated column:

 

MonthAverageNumber = [MonthDays] * [Average]

Then create a measure like:

 

MyMeasure = SUM([MonthAverageNumber]) / SUM(MonthDays)

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Unfortunatelly this also gives me different result

 

Снимок.PNG

 

 I guess thats becouse i have several rows for each month in my data source. Here is it:

 

 

DirectionEOM DateAV PlanMonth #NumberDays
101.31.16-72,54979045131
102.29.16-252,5844382229
103.31.16-63,70552772331
104.30.16-1243,54721430
105.31.16-1693,615029531
106.30.16-684,3135524630
107.31.16-815,8175674731
108.31.16-582,0372591831
109.30.16-0,855819632930
110.31.16-565,8436311031
111.30.16-1094,5205021130
112.31.16-1736,2794411231
201.31.1617319,95131
501.31.1616387,36479131
301.31.169066,485131
401.31.169398,75131
601.31.1618324,5131
202.29.1614860229
502.29.1614084,67444229
302.29.167187,5229
402.29.168158,5229
602.29.1616100229
203.31.1615130331
503.31.1613922,29553331
303.31.167310331
403.31.167985331
603.31.1614950331
204.30.1616060430
504.30.1614338,91866430
304.30.167804,128545430
404.30.168077430
604.30.1613950430
205.31.1616550531
505.31.1614218,31442531
305.31.167865,225611531
405.31.168231,5531
605.31.1613200531
206.30.1617790630
506.30.1614962,64149630
306.30.168421,097065630
406.30.168416,5630
606.30.1612925630
207.31.1618160731
507.31.1615206,49257731
307.31.168813731
407.31.168549,5731
607.31.1613475731
208.31.1617090831
508.31.1615227,61101831
308.31.169023831
408.31.168836,5831
608.31.1614200831
209.30.1617959930
509.30.1616834,61978930
309.30.169957,134789930
409.30.169516930
609.30.1615050930
210.31.16199591031
510.31.1618445,258841031
310.31.1610807,134791031
410.31.16101011031
610.31.16160001031
211.30.16215051130
511.30.1619142,3781130
311.30.1611358,51130
411.30.1610513,51130
611.30.16169001130
212.31.16237551231
512.31.1620351,586941231
312.31.16121611231
412.31.16113851231
612.31.16181501231

 

I understand that it doesn't work becouse of derections column, but I cant figure out how to explain Power BI to sum all rows inside directions, instead of calculatiing average of total rows number....

Sorry, forgot to post my Excel. Not sure why my Excel is different than yours but I'll try again with your data.

 

grandtotal.png



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.