GROUPFIRST
Syntax
GROUPFIRST(<any>; order by any)
Description
This function returns a value in a group as specified by the ordered column's first value.
- If the column used to order the group is a number, then the value used from the order column is the lowest number.
- If the column used to order the group is a string, then the value used from the order column is the lowest number (in string form). If no numbers (in string form) are present, the first capital letter alphabetically is used. If no uppercase letters are present, the first lowercase letter alphabetically is used.
- If the column used to order the group is a date, then the value used from the order column is the earliest date.
This is an aggregate function.Â
Example
Given the following raw data:
Customer_number | Name | Order_number | Item |
---|---|---|---|
2535 | Jon | 101544 | Zamioculcas |
2888 | Mike | 101567 | Spider Lily |
2535 | Jon | 101643 | Datura |
2535 | Jon | 101899 | Dahlia |
5788 | Jon | 102003 | Snapdragon |
2888 | Mike | 102248 | Marguerite |
2535 | Jon | 102282 | Windflower |
2888 | Mike | 102534 | Elephant's Ear |
2535 | Jon | 102612 | Chinese Evergreen |
5788 | Jon | 102617 | Begonia |
5788 | Jon | 102765 | Starfish Plant |
2535 | Jon | 102947 | Hare's Foot Fern |
2535 | Jon | 103001 | Venus Flytrap |
3545 | Monique | 103006 | Red Flame Ivy |
Create a group, using GROUPBY(#RawData!Customer_number), and GROUPBY(#RawData!Name).
Customer_number | Name |
---|---|
2535 | Jon |
2888 | Mike |
3545 | Monique |
5788 | Jon |
Using GROUPFIRST(#RawData!Item;#RawData!Order_number), you can return the first item ordered by each customer.
Customer_number | Name | First_Item |
---|---|---|
2535 | Jon | Zamioculcas |
2888 | Mike | Spider Lily |
3545 | Monique | Red Flame Ivy |
5788 | Jon | Snapdragon |