cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

New Member

## Apply filter on CURRENTGROUP

Hi

I am trying to calculate the difference between the last and previous observations for each ID. In the dataset, I have multiple observations for each ID over time. As a first step, I want to create a new table with the last and previous dates. I m using GROUPBY, but I cannot apply any filter to CURRENTGROUP. What would be a better approach to the problem?

Thanks

NewTable =

GROUPBY(
table,table[ID],
"LastDate",MAXX(CURRENTGROUP(),table[DATE]),
"PreviousDate", MAXX(FILTER(CURRENTGROUP(), table[DATE] < MAXX(CURRENTGROUP(),table[DATE]),table[DATE] )
))

1 ACCEPTED SOLUTION
Super User

@vs531 , In case you need a new column

Diff =

var _max = maxx(filter(Table, [ID] = earlier([ID]) && [Date] < earlier([Date]) ) , [Date])
return
[Score]- Maxx(filter(Table, [ID] = earlier([ID]) && [Date] =_max ) , [Score])

2 REPLIES 2
New Member

Thanks @amitchandak

Super User

@vs531 , In case you need a new column

Diff =

var _max = maxx(filter(Table, [ID] = earlier([ID]) && [Date] < earlier([Date]) ) , [Date])
return
[Score]- Maxx(filter(Table, [ID] = earlier([ID]) && [Date] =_max ) , [Score])

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors