How to get the maximum and minimum value of each group

Hi all !

I am basically trying to get the maximum and minimum date of each group

For example, I have this:

image

And I would like to have this:

image

Hi @NathanDrake

If your date column is of type date then this is very simple to achieve with the -GroupBy- node:

One just needs to group by the name columns and then implement two aggregations, one with the minimum and another with the maximum functions.

This should do the trick :wink:

Please reach out back if this is not clear enough.

Hope it helps.
Best
Ael

6 Likes

Adding to @aworker’s comment, if you want the data returned in “stacked” rows , you can then use the"Unpivoting" node, specifying your min and max date columns (from the GroupBy node) as the “value” columns, and the name column as the “Retained” column

5 Likes

Hi @NathanDrake

Just another solution :grinning: min_max.knwf (26.2 KB)
image
gr. Hans

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.