Home      Functions     Common Solutions      Contact     






MDX Functions:
 
MDX Functions

 
Common Solutions

Common Solutions
 
Resource Links

MDX Books
MDX Related Software
MDX Related Blogs
 
Other Links

Contact Us
 
Microsoft SQL Server Analysis Services Function Page
Function Name: Lag
Category: Navigation
Description: The Lag function returns a member that is n positions before the supplied member within a dimension. Typical uses for the Lag function are to traverse or create a date range.
Syntax: «Member».LAG( «Numeric Expression» )
Technet Link: MDX Lag Function




Typical uses for the Lag function are to traverse or create a date range. For instance, if you want to see n days before a specified date, you could use the following query:
 

SELECT
      {} ON COLUMNS,
      {[Date].[Date].[January 15, 2004].Lag(5)} ON ROWS
FROM
      [Adventure Works]
 
This query will return the member that is 5 positions before the supplied member of January 15, 2004.
 

 
To create a set of days that ranges from 30 days before January 15, 2004 up to January 15, 2004, you would use the following query:
 

SELECT
      {} ON COLUMNS,
      {[Date].[Date].[January 15, 2004].Lag(30):[Date].[Date].[January 15, 2004]} ON ROWS
FROM
      [Adventure Works]
 
 

 
You can also use negative numbers for the numeric expression and the function will return n positions after the specified member. However, it is recommended that you use the Lead function.
 

SELECT
      {} ON COLUMNS,
      {[Date].[Date].[January 15, 2004].Lag(-5)} ON ROWS
FROM
      [Adventure Works]
 
 

 
 

 
Copyright 2008 by MDXpert.com.
 
Terms of Use                              Privacy Statement
 
Site Powered By - WinHost.Com