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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Frequent Visitor

Error while trying to sum and get the average from two calculated columns

Hi all.


So I have the following 3 columns in my table: Name, QTR 1, QTR 2. QTR 1 and 2 are calculated columns that I made to get the difference from other columns.


It's important to note that there might be multiple row entries for the same name as shown above.


So what I'm trying to do is to get the total average in QTR 1 for each name. For example, for Red under QTR 1, the sum would be 17 and so the result should display the average which is 5.66.  This would repeat in QTR 2, so the average for Red would be 3 there.


Finally, the end result should add the two averages together from both columns, so in the case of Red, it would add 5.66 and 3 to return 8.66


I wrote the DAX below but keep running into an error that says something about "function groupby scalar expressions have to be aggregation." 


Not sure how to figure this out. Any help is appreciated!



Total Average by Name = AVERAGEX(GROUPBY('Table', 'Table'[Name], "TotalValue", (AVERAGE('Table'[QTR1]) + AVERAGE('Table'[QTR2]))), [TotalValue])

Community Support
Community Support

Hi @pintobean87 

Try the following measure

Measure = var a=CALCULATE(AVERAGE('Table'[QTR1]),ALLEXCEPT('Table','Table'[Name]))
var b=CALCULATE(AVERAGE('Table'[QTR2]),ALLEXCEPT('Table','Table'[Name]))
return a+b




Best Regards!

Yolo Zhu

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

Frequent Visitor

Or is there just an easier way to do the math than what I'm trying to do?

Helpful resources

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors