Skip to main content
2 of 2
Updated to match OP's edited requirements

EDIT

You can try something like:

=sum(filter(M2:M,D2:D="Store 1",A2:A=max(filter(A2:A,D2:D="Store 1"))))

The inner filter returns every row in A2:A (dates) where D2:D (stores) contains 'Store 1'), we then take the max of this and use it in the outer filter to return every row in M2:M (sales) where A2:A matches that maximum date (and D2:D still contains 'Store 1'), then finally we take the sum of those values.