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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
rjaramillo
New Member

Creating a sum based on averages

Hello,

 

I have a category column, subcategory column, and a cost column.  I have a slicer to choose a specific category, and I have a chart below it that showcases the average cost for each subcategory.  I am trying to see the total sum of the average cost but the resulting total is not what I'm expecting.  

 

The formula I'm using is SUMX(VALUES([subcategory column]),AVERAGE([cost column]))

 

Below is a snippit of what I'm getting.  The left column is the standard Average of the cost column and the right column is the calculated measure I'm trying to create.

 

Any help would be super.  Thanks!

 

rjaramillo_0-1650572781698.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rjaramillo ,

 

I think there are two kinds of ways to create measures to calculate correct average total.

Measure1:

 

Measure 2 = 
SUMX(VALUES('Table'[subcategory]),CALCULATE( AVERAGE('Table'[cost])))

You need to add "CALCULATE" function before "AVERAGE", it will consider filter context and give you correct result.

 

Measure2:

Measure1 = 
VAR _SUMMARIZE = SUMMARIZE('Table','Table'[subcategory],"Avg by subcategory",CALCULATE(AVERAGE('Table'[cost])))
RETURN
SUMX(_SUMMARIZE,[Avg by subcategory])

 Result is as below.

RicoZhou_0-1650957821918.png

Best Regards,
Rico Zhou

 

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

 

View solution in original post

4 REPLIES 4
danextian
Super User
Super User

hI @rjaramillo,
I tested your approach and the formula worked find on my end. I did get the expected result which is the sum of the average. Here is a sample pbix - https://drive.google.com/file/d/11e0N1DPmJyr7k1U2rFlwFuTvhivv3yYq/view?usp=sharing





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

So that's what I'm expecting as well I thought it would be pretty straightforward but maybe there's something behind the scenes?  I'm not sure if there's another way to get the answer

Anonymous
Not applicable

Hi @rjaramillo ,

 

I think there are two kinds of ways to create measures to calculate correct average total.

Measure1:

 

Measure 2 = 
SUMX(VALUES('Table'[subcategory]),CALCULATE( AVERAGE('Table'[cost])))

You need to add "CALCULATE" function before "AVERAGE", it will consider filter context and give you correct result.

 

Measure2:

Measure1 = 
VAR _SUMMARIZE = SUMMARIZE('Table','Table'[subcategory],"Avg by subcategory",CALCULATE(AVERAGE('Table'[cost])))
RETURN
SUMX(_SUMMARIZE,[Avg by subcategory])

 Result is as below.

RicoZhou_0-1650957821918.png

Best Regards,
Rico Zhou

 

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

 

the CALCULATE part is what I was missing!  Thank you so much!

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.