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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
uk-roberto92
Frequent Visitor

Average by group ignoring Sub-Group

Hi,

 

I have a table of the form:

 

Id     Group   Sub-Group    value

1          A           1A                 10

2          A            2C                 50

3          B            1A                 12   

10        C            2A                 5

11        A           1B                  100

110      C             3C                 1000

n          xx            xxx                  nnnn

 

I built a barplot for AVG(value) by Sub-Group and I'd like to show the AVG(value) by Group as a line.

 

I tried to calculate the AVG(value) by Group as 

Avg value by Group=
CALCULATE(
    AVERAGE(
        Table[value]
    ),
    ALLEXCEPT(
        Table, Table[Group]
    )
)
 
But as you can see below (blue line) this is just same as Avg(value) by Subgroupm, while I would expect a straight line cutting the bars.

ukroberto92_0-1749637659108.png

 

Any help on this?

Thx

 

 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @uk-roberto92 
You can use a dax measure :

Group average = 
VAR selectedGroup = SELECTEDVALUE('Table'[Group])
VAR AVG_ =
CALCULATE(
AVERAGEX(
SUMMARIZE('Table', 'Table'[Group], "Sum_", AVERAGE('Table'[Value])),
[Sum_]
),
ALLSELECTED('Table'[Sub-Group]),
KEEPFILTERS('Table'[Group] = selectedGroup)
)
RETURN
AVG_

 

Important Notes:

  1. Tooltip Dependency for Sorting
    To sort the bars according to the group, you need to add the Group field into the Tooltips section — as shown in the image.
    This ensures the "Group average" line aligns with each bar correctly by maintaining group context.

Ritaf1983_1-1749791216009.png

2. Granularity Mismatch – Line May Disappear
Due to the granularity difference between the Sub-Group (X-axis) and Group average (aggregated by Group), the line won’t appear for the first bar unless you structure your visual hierarchically — like in the second image where the hierarchy is visualized.

Ritaf1983_2-1749791262719.pngRitaf1983_3-1749791289253.png

3. 

Visual Misinterpretation – Lines Suggest Trends
A line chart (or combo chart with a line) is typically interpreted by users as a trend over time.
Since this visual is not time-based, to avoid misleading your users, I recommend replacing the line with just markers, like in the third image.
This keeps the message clear — you're showing averages per group, not a time-based trend.

Alternatively, you can:

  • Show a single visual with the overall average,

Ritaf1983_4-1749791349000.png

 

  • And create a second chart showing the delta from group average.

The pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @uk-roberto92,

As we haven’t heard back from you, we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Regards,
Vinay Pabbu

Ritaf1983
Super User
Super User

Hi @uk-roberto92 
You can use a dax measure :

Group average = 
VAR selectedGroup = SELECTEDVALUE('Table'[Group])
VAR AVG_ =
CALCULATE(
AVERAGEX(
SUMMARIZE('Table', 'Table'[Group], "Sum_", AVERAGE('Table'[Value])),
[Sum_]
),
ALLSELECTED('Table'[Sub-Group]),
KEEPFILTERS('Table'[Group] = selectedGroup)
)
RETURN
AVG_

 

Important Notes:

  1. Tooltip Dependency for Sorting
    To sort the bars according to the group, you need to add the Group field into the Tooltips section — as shown in the image.
    This ensures the "Group average" line aligns with each bar correctly by maintaining group context.

Ritaf1983_1-1749791216009.png

2. Granularity Mismatch – Line May Disappear
Due to the granularity difference between the Sub-Group (X-axis) and Group average (aggregated by Group), the line won’t appear for the first bar unless you structure your visual hierarchically — like in the second image where the hierarchy is visualized.

Ritaf1983_2-1749791262719.pngRitaf1983_3-1749791289253.png

3. 

Visual Misinterpretation – Lines Suggest Trends
A line chart (or combo chart with a line) is typically interpreted by users as a trend over time.
Since this visual is not time-based, to avoid misleading your users, I recommend replacing the line with just markers, like in the third image.
This keeps the message clear — you're showing averages per group, not a time-based trend.

Alternatively, you can:

  • Show a single visual with the overall average,

Ritaf1983_4-1749791349000.png

 

  • And create a second chart showing the delta from group average.

The pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi,

 

sorry I must have duplicated this post by mistake... I eventually went by the code proposed in https://community.fabric.microsoft.com/t5/Desktop/Average-by-group-ignoring-sub-groups/m-p/4728951, which is something similar to your proposal. 

 

However just tried your solution and this works as well!

Thanks a lot

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.