Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


lag function calculation


lag function calculation

Author
Message
sruthireddy21
sruthireddy21
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 71
Hi I have situation



I am trying to calculate lag period from the present quarter to last quarter



time hierarchy has

year(level1)

quarter(level2)



i wanted to see percent rejected measure in such a way that



2007Quarter4 -''percent rejected" shows 2007Quarter3 value

and

2007Quarter3 -''percent rejected" shows 2007Quarter2 value

2007Quarter4 -''percent rejected" shows 2007Quarter3 value

and

2007Quarter1 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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search