﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / Business Intelligence  / lag function calculation / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 01:02:36 GMT</lastBuildDate><ttl>20</ttl><item><title>lag function calculation</title><link>http://www.sqlservercentral.com/Forums/Topic567813-147-1.aspx</link><description>Hi I have  situation  I am trying to calculate lag period from the present quarter to last quarter time hierarchy hasyear(level1)quarter(level2) i wanted to see percent rejected measure in such a way that 2007Quarter4 -''percent rejected" shows 2007Quarter3 valueand2007Quarter3 -''percent rejected" shows 2007Quarter2 value2007Quarter4 -''percent rejected" shows 2007Quarter3 valueand2007Quarter1 should show  -''percent rejected" shows 2006Quarter4 value( I am not able to see these values)when I gave the above code:( [Time].[TimeHierarchy].CurrentMember.Lag(1), [Measures].[percent rejected] ) this is fine with year level ,but at quarter level...for example 2008 Q1 is not picking up the value of 2007 Q4 it shows null values when I try this above code iif( [Time].[TimeHierarchy].CurrentMember.Level.Ordinal = 2,  (([Time].[TimeHierarchy].CurrentMember.Lag(1)),[Measures].[percent rejected] ), (([Time].[TimeHierarchy].CurrentMember.Lag(1)), [Measures].[percent rejected] )) still the same thing happens in the result  </description><pubDate>Thu, 11 Sep 2008 08:51:44 GMT</pubDate><dc:creator>sruthireddy21</dc:creator></item></channel></rss>