Aggregating the First Value in the Group By of a dataset

Aggregating the First Value in the Group By of a dataset

Hi

I am trying to get the following Aggregate Formula to work in my chart, but cannot seem to get the right format. I have a series of data that I am running an include_groupby and want to SUM only a column in the first row of each group. So for example. I have Customer Sales data. Customers are grouped into regions. I want to get the latest sales entry for each customer and then sum those results. I have sorted my data using the date field so I can fetch the first record in the group and it should be fine

Here is what I have tried:

1. sum(include_groupby(max("Sales"),"Region")). This gets the maximum sales amount in the group. But I want the latest one

2. sum(include_groupby(first_value("Sales"),"Region")). this produces a format error

3. sum(include_groupby(avg(first_value( avg("Sales") )),"Region")). This was a long shot, but it throws a format error

Any ideas in how I go about achieving this.

Regards
Andrew