Alteryx Designer Desktop Discussions

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

Max Record based on Date

JDong
8 - Asteroid

Hello Team @atcodedog05 ,

 

Please refer to this sample dataset from my overall data

 

Last Modified ByLastModifiedDateCompany
Jack09.12.2020 07:46ABC Tech
Jack11.12.2020 14:35ABC Tech
Peter21.12.2020 06:15FDE Auto
Winson30.10.2020 12:15HIC Fenster
Blake30.10.2020 12:15IRT Iron
Winson14.12.2020 10:11HIC Fenster

 

 

I need to retreive one line of record and group the records based on max of modified date

 

So end result in this case would be 

 

Last Modified ByLastModifiedDateCompany
Jack11.12.2020 14:35ABC Tech
Peter21.12.2020 06:15FDE Auto
Blake30.10.2020 12:15IRT Iron
Winson14.12.2020 10:11HIC Fenster

 

Can you please advise with how this can be achieved in Alteryx.

 

Thanks

13 REPLIES 13
Kenda
16 - Nebula
16 - Nebula

Hi @JDong 

 

Try first sorting your data by Last Modified By then by LastModifiedDate. From there, use the sample tool to keep the last record, grouping by the Last Modified By field.

 

Note - you may have to edit your date field first so that it is in the Alteryx date format.

 

Hope this helps!

JDong
8 - Asteroid

@Kenda 

 

Thanks this is helpful.

 

In my actual dataset I have derived close to 40 columns, so the grouping is not happening on all columns. Also the date now shows same for all rows of data.

 

Will it help if I add a summerize tool after the Sample tool ?

 

Gallop_0-1610637930109.png

Thanks

Kenda
16 - Nebula
16 - Nebula

@JDong 

 

I'm not sure I understand exactly without seeing your data, but the Sample tool has a grouping functionality in it. Whichever fields you need to group by when selecting which rows to keep can be done within this tool. 

 

Kenda_0-1610639288433.png

 

JDong
8 - Asteroid

@Kenda 

 

Not all records are shown after grouping in Sample tool based on Name.

 

Would it work on grouping rest of the columns ?

 

Thanks

Kenda
16 - Nebula
16 - Nebula

@JDong  Right. Not all records are shown because we told the sample tool to only keep the last record for each unique value of the name field. If you group by additional fields, it will keep the last record for each unique combination of fields that you select. 

 

Take this data for example:  

NameGroupRecord
Johna1
Kathya2
Winstona3
Matta4
Carolb5
Mattb6
Johna7
Winstonb8
Carolb9
Kathya10

 

If you use the sample tool to keep the last record and only group by the Name field, you would get this result (one record per name):

NameGroupRecord
Carolb9
Johna7
Kathya10
Mattb6
Winstonb8

 

If you use the sample tool to keep the last record and group by both Name and Group, this would be the result (one record per each unique Name & Group combination):

NameGroupRecord
Carolb9
Johna7
Kathya10
Matta4
Mattb6
Winstona3
Winstonb8

 

So it really just depends on what your data looks like and what your goal is. Hope that helps!

JDong
8 - Asteroid

@Kenda 

 

Thanks !

 

This is a nice solution, but problem is I have 40 columns and on grouping on different columns I get different results.

 

Is there an easier way to solve this use case ?

 

 

Emil_Kos
17 - Castor
17 - Castor

Hi @JDong,

 

If you want to have one line per grouping you can use summarize tool and max function.

 

If this isn't something that you have been looking for please let me know:

 

Emil_Kos_0-1610912875758.png

The output:

 

Emil_Kos_1-1610912890630.png


Please mark my post as a solution if this was helpful!

JDong
8 - Asteroid

@Emil_Kos 

 

Thanks !

 

If there are more than 1 record in same date but time is different, it does not get the max date.

 

Any way based on the date and time we can select a single max value ?

 

 

Emil_Kos
17 - Castor
17 - Castor

Hi @JDong,

 

It will show only 1 max value. I just tested it and it works. Please check the line 5 and 7.

 

Emil_Kos_0-1610916894237.png

 

And the output:

Emil_Kos_1-1610916925749.png

Alternatively, you can use the sample tool on the MAX date time in order to be sure. 

 

Labels