Reza Rad shows how to get the last item in each group using Power Query:
Scenario that I want to solve as an example is this:
FactInternetSales has sales transaction information for each customer, by each product, each order date and some other information. We want to have a grouped table by customer, which has the number of sales transaction by each customer, total sales amount for that customer, the first and the last sales amount for that customer. First and last defined by the first and last order date for the transaction.
In T-SQL, this sounds like the job of window functions. In Power BI, we write M.