Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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               ...
  • Greg_Deckler's avatar
    Greg_Deckler
    4 years ago

    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])