This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
To get the first value you can use the ISFIRST function:
https://msdn.microsoft.com/en-us/library/azure/dn966248.aspx
I think there is no built in function to get the last value at the moment,