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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Group by + avg

Hello guys,

I need to help with following group by and average dax formula

 

my data

 

y_m              value
2022_1              1
2022_1              2
2022_1              3
2022_2              4
2022_2              5
2022_2              6
2022_3              7
2022_3              8
2022_3              9

 

and I would like to get

 

y_m              value
2022_1              2
2022_2              5
2022_3              8

 

I tried to this dax formula

measure = GROUPBY(Date_Dim,Date_Dim[y_m],"result",AVERAGEX(CURRENTGROUP(),fact[abs(value)]))
 
but receive an error:
The CALCULATE formula cannot be used in expression argument for the GROUPBY() function

any idea ? how to do it ?
1 ACCEPTED SOLUTION

@Anonymous Measures cannot return tables. Your original formula works for me to create a table:

Table 2 = GROUPBY('Table','Table'[y_m],"result",AVERAGEX(CURRENTGROUP(),'Table'[value]))

Also, it works in a measure to create a table var:

Measure = 
    VAR __Table = GROUPBY('Table','Table'[y_m],"result",AVERAGEX(CURRENTGROUP(),'Table'[value]))
    VAR __y_m = MAX('Table'[y_m])
RETURN
    MAXX(FILTER(__Table,[y_m] = __y_m),[result])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Anonymous Just use measure = AVERAGE('Table'[value])



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hello @Greg_Deckler 

but I need that output will be table not one value

@Anonymous Measures cannot return tables. Your original formula works for me to create a table:

Table 2 = GROUPBY('Table','Table'[y_m],"result",AVERAGEX(CURRENTGROUP(),'Table'[value]))

Also, it works in a measure to create a table var:

Measure = 
    VAR __Table = GROUPBY('Table','Table'[y_m],"result",AVERAGEX(CURRENTGROUP(),'Table'[value]))
    VAR __y_m = MAX('Table'[y_m])
RETURN
    MAXX(FILTER(__Table,[y_m] = __y_m),[result])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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