Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dd_au
New Member

Group By - Filter by latest date within weekending

Hi all, 

 

Pretty new to PowerBi so apologies for the basic question. 


I've been using Group By but it's no longer achieving what I need and want to find a better way to group values. I want to group by week ending, item, and then the latest result in each phase. Someone had recommended using aggregation and the max operation on the phases to achieve the last results but as you can see from the example below H3 is 4 and H5 is 1 so it would return a value of 4 when in actuality at weeks ending the last value recorded was 1. 

I messed around with it a bit and tried the max value on the date and then the aggregate groupings though it still results in the incorrect result. 

 

dd_au_0-1710223985256.png



1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @dd_au ,

 

You're correct, using MAX aggregators in the Group By isn't going to help you here - you need to group to a nested table then select the row of data which has the MAX of [date].

 

Try this:

1) Group By [week ending] and [item]. For the aggregate column, choose the 'All Rows' operator and call this column 'data'.

2) Now you have your nested table column, add a new custom column like this:

Table.Max([data], "date")

You will now have a nested Record column that contains the full row of data for the max [date] value.

3) Expand the nested Record column, choosing whichever columns you want to reinstate back to the table.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @dd_au ,

 

You're correct, using MAX aggregators in the Group By isn't going to help you here - you need to group to a nested table then select the row of data which has the MAX of [date].

 

Try this:

1) Group By [week ending] and [item]. For the aggregate column, choose the 'All Rows' operator and call this column 'data'.

2) Now you have your nested table column, add a new custom column like this:

Table.Max([data], "date")

You will now have a nested Record column that contains the full row of data for the max [date] value.

3) Expand the nested Record column, choosing whichever columns you want to reinstate back to the table.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thanks Pete! This worked a treat. This will be pretty handy in the future. 

Cheers, 

DD

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors