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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
frithjof_v
Community Champion
Community Champion

Average of averages within group

Hi,

 

I am trying to make a measure to calculate the average per city. It shall be the average of the visible values in the "Average of amount" column per city.

 

As shown below:

frithjof_v_0-1716738222079.png

 

I have just hardcoded the values in the rightmost column, to show what I am trying to achieve.

 

How can I make such a measure in DAX?

 

 

 

The data looks like this:

frithjof_v_6-1716735688318.png

 

Thank you! 😀

1 ACCEPTED SOLUTION
frithjof_v
Community Champion
Community Champion

This measure solved it:

 

Avg per city = 
CALCULATE(
    AVERAGEX(
        SUMMARIZE(
            Sales, 
                Sales[City], 
                Sales[Product], 
                "AvgAmount", AVERAGE(Sales[Amount])
        ),
        [AvgAmount]
    ), 
    ALLSELECTED(Sales[Product])
)

 

View solution in original post

4 REPLIES 4
frithjof_v
Community Champion
Community Champion

This measure solved it:

 

Avg per city = 
CALCULATE(
    AVERAGEX(
        SUMMARIZE(
            Sales, 
                Sales[City], 
                Sales[Product], 
                "AvgAmount", AVERAGE(Sales[Amount])
        ),
        [AvgAmount]
    ), 
    ALLSELECTED(Sales[Product])
)

 

HKIndia
Helper I
Helper I

I think, Is this the result you want. I am getting this result without any creating measure you can see in values section in rigtht side changed to average instead of Sum. let me know if it resolved your query 

HKIndia_0-1716737302996.png

 

Thank you @HKIndia,

 

I noticed there was an over-simplification in the sample data. I think that is why the row subtotals gave the seemingly correct answers.

 

However, that was not my intention. I have corrected the sample data now. 

frithjof_v
Community Champion
Community Champion

Here is the sample data in CSV format (semi-colon separated):

 

 

City;Product;Amount
Oslo;Apple;10
Copenhagen;Apple;20
Stockholm;Apple;30
Helsinki;Apple;40
Reykjavik;Apple;50
Oslo;Banana;50
Copenhagen;Banana;40
Stockholm;Banana;30
Helsinki;Banana;20
Reykjavik;Banana;10
Reykjavik;Grape;20
Helsinki;Grape;30
Stockholm;Grape;40
Copenhagen;Grape;50
Oslo;Grape;60
Reykjavik;Orange;5
Helsinki;Orange;10
Stockholm;Orange;15
Copenhagen;Orange;20
Oslo;Orange;25
Oslo;Carrot;5
Copenhagen;Carrot;10
Stockholm;Carrot;15
Helsinki;Carrot;20
Reykjavik;Carrot;25
Oslo;Potato;35
Copenhagen;Potato;45
Stockholm;Potato;55
Helsinki;Potato;65
Reykjavik;Potato;75
Reykjavik;Turnips;10
Helsinki;Turnips;20
Stockholm;Turnips;40
Copenhagen;Turnips;50
Oslo;Turnips;60
Reykjavik;Cauliflower;15
Helsinki;Cauliflower;25
Stockholm;Cauliflower;35
Copenhagen;Cauliflower;45
Oslo;Cauliflower;55
Oslo;Fine;35
Copenhagen;Fine;45
Stockholm;Fine;55
Helsinki;Fine;65
Reykjavik;Fine;75
Oslo;Whole grain;45
Copenhagen;Whole grain;55
Stockholm;Whole grain;65
Helsinki;Whole grain;75
Reykjavik;Whole grain;85
Reykjavik;Rhye;85
Helsinki;Rhye;75
Stockholm;Rhye;65
Copenhagen;Rhye;55
Oslo;Rhye;45
Reykjavik;Oat;75
Helsinki;Oat;65
Stockholm;Oat;55
Copenhagen;Oat;45
Oslo;Oat;55
Reykjavik;Grape;10
Helsinki;Grape;5
Stockholm;Grape;15
Copenhagen;Grape;20
Oslo;Grape;10
Reykjavik;Orange;10
Helsinki;Orange;20
Stockholm;Orange;10
Copenhagen;Orange;30
Oslo;Orange;25
Oslo;Carrot;10
Copenhagen;Carrot;25
Stockholm;Carrot;10
Helsinki;Carrot;25
Reykjavik;Carrot;15
Oslo;Potato;10
Copenhagen;Potato;50
Stockholm;Potato;30
Helsinki;Potato;20
Reykjavik;Potato;10
Reykjavik;Turnips;25

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.