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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

GROUPBY + ALLEXCEPT functions

Hello, I have this table from which I want to get the average qty per order.

guillaume_boism_0-1638821518789.png

1) I have this measure to help me achieve it.

Measure =

Var Group_1=

GROUPBY(

'Table',

       'Table'[Month],

       'Table'[Order],

       'Table'[Product Code],

                             "Sum",sumx(CURRENTGROUP(),'Table'[Qté]))

Return

Calculate(Averagex(Group_1,[Sum]),ALLEXCEPT('Table','Table'[Month]))

 

2) The result is not what I want. I used the allexcept function (see in red above) to see the same result for every product code depending on the month. I should see 6 for every product in Jan and 7 for every product in Jun.

 

guillaume_boism_2-1638821704823.png

 

Please note that I gave a simple generic example, my real formula contains nested GroupBys so I need a solution that will still use groupby function.

 

Thank you!

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I think something simpler might work. Is this what you're after?

Measure =
VAR Group_1 =
    GROUPBY (
        'Table',
        'Table'[Order],
        "Sum", SUMX ( CURRENTGROUP (), 'Table'[Qté] )
    )
RETURN
    AVERAGEX ( Group_1, [Sum] )

 

View solution in original post

3 REPLIES 3
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

I tested the solution provided by @AlexisOlson  and was able to get the correct result.

vhenrykmstf_0-1639472333454.png

If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Best Regards,
Henry


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

AlexisOlson
Super User
Super User

I think something simpler might work. Is this what you're after?

Measure =
VAR Group_1 =
    GROUPBY (
        'Table',
        'Table'[Order],
        "Sum", SUMX ( CURRENTGROUP (), 'Table'[Qté] )
    )
RETURN
    AVERAGEX ( Group_1, [Sum] )

 

jeroendekk
Resolver V
Resolver V

Hi @Anonymous 
It would help if you can post your sample data in a format that can be copied, so people here can make mock report to check if their proposed solution works.

Best regards,
Jeroen

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.