Need is to find the top 6 of production "values" between operators("op"). Secondly to average them across each op. I need help with the DAX code.
I tried creating a separate table using topN to find top values. Then used AverageX, CurrentGroup and GroupBy. The error is that GroupBy statement must find the average across CurrentGroup, must refer to CurrentGroup or a constant.
Table =
GROUPBY (
GROUPBY (
fat,
'fat'[op],
"topn", TOPN( 6, fat, fat[Value],DESC)
),
'fat'[op],
"mn",SUMX( CURRENTGROUP (), [topn] )
)
This is easier done in R:
dt<-read.table("data2.csv", TRUE)
library(plyr)
n=6 #or other
df1<-ddply(dt,~name,summarise,mean=mean(tail(sort(val),n)))