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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jeanilieski
Frequent Visitor

Keeping latest dates in multiple columns grouped by category in another column

Dear all, I have the following table:

jeanilieski_1-1692042185423.png

and I would like to achive the following result for each of the categories in the first column:

jeanilieski_3-1692042454965.png

Shortly, I need a new table where dates will be "compressed" into one row. In case where more then one dates per column are availbale, the closest to today's date should be prefered (e.g. in the penultimate column 08.06 is prefered over 09.01). This should be achived ideally in PowerQuery. 

Many, many thanks in advance!

 

1 REPLY 1
wdx223_Daniel
Super User
Super User

=Table.Group(PreviousStepName,"Categories",List.Transform(List.Skip(Table.ColumnNames(PreviousStepName)),(x)=>{x,each List.MinN(Table.Column(_,x),1,each Number.Abs(Duration.TotalDays(DateTime.From(_)-DateTime.LocalNow()))){0}?}))

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors