When using the first and last functions in a custom subtotal, the values are displayed sorted by the metric by default.

In order to display the first and last values of the attribute, the functions' parameters need to be changed to Sort By the attribute desired.

Now the report will display the first and last value of the attribute.
