cancel
Showing results for
Did you mean:
Highlighted
Regular 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?

Thanks,

Shiv

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: DAX GROUPBY each group

```Table 2 =
VAR __tmpTable = SUMMARIZE('Table31',[Name],"__MaxRate",MAX('Table31'[Rate]))
RETURN

Table31 is my base table.

Proud to be a Datanaut!

8 REPLIES 8
Super User

## Re: DAX GROUPBY each group

Maybe something like this:

```Measure Rate = MAX([Rate])

Measure Day =
MAXX(FILTER('Table',[Rate]=[Measure Rate]),[Day])
```

Put these two measures in a table viz with [Name].

Proud to be a Datanaut!

Regular Visitor

## Re: DAX GROUPBY each group

Thanks @Greg_Deckler

Is it possible to get a calculated table?

Member

## Re: DAX GROUPBY each group

Why we can't use an expression like below:

`NewTable = CALCULATETABLE(Table1, GROUPBY(Table1, Table1[Day],Table1[Name], "maxrate", MAX(Table1[Rate])))`

Regular Visitor

## Re: DAX GROUPBY each group

@elahemeydani 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()"

Member

## Re: DAX GROUPBY each group

Yes, Exactly. I receive the same error. And I don't understand what is the probelm

Super User

## Re: DAX GROUPBY each group

```Table 2 =
VAR __tmpTable = SUMMARIZE('Table31',[Name],"__MaxRate",MAX('Table31'[Rate]))
RETURN

Table31 is my base table.

Proud to be a Datanaut!

Member

## Re: DAX GROUPBY each group

I suggest you check out the URL below:

one of the best to describe the GROUP BY and aggregation functions.

Community Support Team

Hi @shivkonar,