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
uk-roberto92
Frequent Visitor

Average by group ignoring sub-groups

Hi,

 

I have a table of the form

Id     Group    SubGroup    Value

1         A              1a             10

2         A               3a               1

3         B               2c              100

4        A               1a                4

10       B               1a               80

11       B               2c                1000

43      C                1b               2

nn       xx               yy              aaa

 

I have the AVG(value) by subgroup as barplot and I'd like to add a line showing AVG(value) by Group.

I tried with the measure:

 

CALCULATE(
    AVERAGE(
        Table[value]
    ),
    ALLEXCEPT(
        Table, Table[Group]
    )
)

 

but this is just  showing the avg(value) by subgroup as well, below.

ukroberto92_0-1749655531172.png

I would rather expect a straight line cutting through the subgroups...

 

Any help on this?

Thx

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @uk-roberto92 ,
Thank you for reaching out to the Microsoft fabric community forum. Also, thanks @johnt75 , for those valuable insights for this thread.

I tried to recreate it on my local with the sample data.Please follow the below steps:
1.Create a measure for Bar (per SubGroup) using below:

AvgValueBySubGroup = AVERAGE('Table'[Value])

2.Create a measure for Line using below:


AvgGroupValueForLine =

VAR CurrentGroup = SELECTEDVALUE('Table'[Group])

RETURN

    CALCULATE(

        AVERAGE('Table'[Value]),

        REMOVEFILTERS('Table'[SubGroup]),

        FILTER(

            ALL('Table'),

            'Table'[Group] = CurrentGroup

        )

    )

3. Use a Line and Clustered Column Chart and place Group and SubGroup as a hierarchy on the X-Axis. Add AvgValueBySubGroup to Column Values , and add AvgGroupValueForLine to Line Values to display a flat line representing the Group-level average across its SubGroups.

Please refer the sceenshot and file for your reference:

 

vpagayammsft_0-1749707273548.png

I hope this answer meets your requirements.If so, give us kudos and consider acceptin git as solution. If still facing any issue in resolving the issue, feel free to reachout!



Regards,
Pallavi G.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @uk-roberto92 ,
Thank you for reaching out to the Microsoft fabric community forum. Also, thanks @johnt75 , for those valuable insights for this thread.

I tried to recreate it on my local with the sample data.Please follow the below steps:
1.Create a measure for Bar (per SubGroup) using below:

AvgValueBySubGroup = AVERAGE('Table'[Value])

2.Create a measure for Line using below:


AvgGroupValueForLine =

VAR CurrentGroup = SELECTEDVALUE('Table'[Group])

RETURN

    CALCULATE(

        AVERAGE('Table'[Value]),

        REMOVEFILTERS('Table'[SubGroup]),

        FILTER(

            ALL('Table'),

            'Table'[Group] = CurrentGroup

        )

    )

3. Use a Line and Clustered Column Chart and place Group and SubGroup as a hierarchy on the X-Axis. Add AvgValueBySubGroup to Column Values , and add AvgGroupValueForLine to Line Values to display a flat line representing the Group-level average across its SubGroups.

Please refer the sceenshot and file for your reference:

 

vpagayammsft_0-1749707273548.png

I hope this answer meets your requirements.If so, give us kudos and consider acceptin git as solution. If still facing any issue in resolving the issue, feel free to reachout!



Regards,
Pallavi G.

Hey @Anonymous thanks a lot, I was stuck on this for last 2 days and with the measure and the hierarchy it's working exactly as expected!

johnt75
Super User
Super User

ALLEXCEPT will not work in this instance because there is no explicit filter on the group column.

Try

Avg by group =
CALCULATE (
    AVERAGE ( 'Table'[Value] ),
    REMOVEFILTERS ( 'Table' ),
    VALUES ( 'Table'[Group] )
)

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.