A union of curiosity and data science

Knowledgebase and brain dump of a database engineer


MDX Query Examples - Item Lag, Lead and Tail

-- Using Tail Non Empty

Order (	
	{
		TAIL(
			NONEMPTY(
			 [Sales Shipping Date PST].[Fiscal Periods].[Standard Date] 
				, [Measures].[Order Count]
			) , 1
		).item(0).lag(89)
		:  
		TAIL(
			NONEMPTY( [Sales Shipping Date PST].[Fiscal Periods].[Standard Date] 
				, [Measures].[Order Count]
			) , 1
		).item(0)
	
	}
	, [Sales Shipping Date PST].[Fiscal Periods].currentmember.member_value
	, DESC	
)



-- between two tails
TAIL(NONEMPTY([Sales Shipping Date PST].[Fiscal Year And Period Label].children, [Measures].[Order Count]) , 1).item(0).lag(2)
	:
TAIL(NONEMPTY([Sales Shipping Date PST].[Fiscal Year And Period Label].children, [Measures].[Order Count]) , 1).item(0)



 

 

Add comment