Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Returns the member that is a specified number of positions before a specified member at the member's level.
Member positions within a level are determined by the attribute hierarchy's natural order. The numbering of the positions is zero-based.
If the specified lag is zero, the Lag function returns the specified member itself.
If the specified lag is negative, the Lag function returns a subsequent member.
The Lag function is similar to the Lead function, except that the Lead function looks in the opposite direction to the Lag function. That is, Lag(n) is equivalent to Lead(-n).