Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Select latest data for each year

crefsgaard
6 - Meteoroid

Hi,

 

I have some data looking like this

 

idyeardate
1year 12015-09-30 16:33:53.000
1year 22016-09-30 16:33:53.000
1year 32017-09-30 16:33:53.000
2year 12015-09-30 16:33:53.000
2year 22016-09-30 16:33:53.000
2year 22016-10-30 16:33:53.000
2year 32017-09-30 16:33:53.000

 

For each year, I only want to choose the latest date within the year. That means, I wish an output of date, that looks like this

 

idyeardate
1year 12015-09-30 16:33:53.000
1year 22016-09-30 16:33:53.000
1year 32017-09-30 16:33:53.000
2year 12015-09-30 16:33:53.000
2year 22016-10-30 16:33:53.000
2year 32017-09-30 16:33:53.000

 

In a programming language, I would loop through each year for each id, and choose rows based on the latest date. But do you guys have any idea on how to do this easily in Alteryx? Thank you very much in advance.

2 REPLIES 2
ivoller
12 - Quasar

Use the Summarize tool and group by Id, Year and Max of date

 

 2018-10-01_12-52-58.png

tcroberts
12 - Quasar

You can pass your input to a summarize tool, and use the following commands:

Group By: ID, Year

Max: Date

 

Note that it will be necessary for your Date column to be a DateTime type in order to perform the MAX operation.

 

Here's a screenshot:

 

Spoiler
summarize_max_dates.PNG

Let me know if you need clarification, or I've missed something,

Cheers!
Labels