cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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])

2 REPLIES 2
Community Support

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``````

Output

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?

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

#### Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors