Forum Discussion
shivkonar
7 years agoFrequent Visitor
DAX GROUPBY each group
Hi, I have a table like below in Power BI: I want a table which return MAX(Rate) for each group, along with the group i.e. a table like below: How can I achieve this? Than...
- 7 years ago
Table 2 = VAR __tmpTable = SUMMARIZE('Table31',[Name],"__MaxRate",MAX('Table31'[Rate])) RETURN ADDCOLUMNS(__tmpTable,"__Day",MAXX(FILTER(ALL('Table31'),[Rate]=[__MaxRate]),[Day]))Table31 is my base table.
Anonymous
7 years agoNot applicable
Why we can't use an expression like below:
NewTable = CALCULATETABLE(Table1, GROUPBY(Table1, Table1[Day],Table1[Name], "maxrate", MAX(Table1[Rate])))
shivkonar
7 years agoFrequent Visitor
Anonymous I get this error
"Function GROUPBY sclar expressions have to be Aggregation functions over CurrentGroup(). The expression of each Aggregation has to be either a constant or direct reference the columns in CurrentGroup()"
- Anonymous7 years agoNot applicable
Yes, Exactly. I receive the same error. And I don't understand what is the probelm
- Greg_Deckler7 years agoCommunity Champion
Table 2 = VAR __tmpTable = SUMMARIZE('Table31',[Name],"__MaxRate",MAX('Table31'[Rate])) RETURN ADDCOLUMNS(__tmpTable,"__Day",MAXX(FILTER(ALL('Table31'),[Rate]=[__MaxRate]),[Day]))Table31 is my base table.