dbTalk Databases Forums  

List the products whos unit sales increasing for the last 4 months

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss List the products whos unit sales increasing for the last 4 months in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
cps
 
Posts: n/a

Default List the products whos unit sales increasing for the last 4 months - 06-23-2005 , 02:39 AM






hai all
i want a query for the above subject which
analyse the unit sales of products which are increasing for the last four
(or) months

can anyone help me?

Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: List the products whos unit sales increasing for the last 4 months - 06-27-2005 , 10:42 PM






This query for the Foodmart Sales cube lists all Product Subcategories
whose unit sales are rising in the last 4 months of 1997 (ie. in each of
Sep-Dec):

Quote:
With Member [Measures].[SalesTrend] as
'Sgn([Measures].[Unit Sales] -
([Measures].[Unit Sales], [Time].PrevMember))'
Member [Measures].[4MonthTrend] as
'Sum(LastPeriods(4,[Time].CurrentMember),
[Measures].[SalesTrend])'

Select {[Time].[1997].[Q3].[8]:
[Time].[1997].[Q4].[12]} on columns,
Filter([Product].[Product Subcategory].Members,
([Measures].[4MonthTrend],
[Time].[1997].[Q4].[12]) = 4) on rows
from Sales
where ([Measures].[Unit Sales])
Quote:


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #3  
Old   
pras
 
Posts: n/a

Default Re: List the products whos unit sales increasing for the last 4 months - 06-28-2005 , 06:36 AM



Hi ,

I couldn't get the hang of
==================================
'Sgn([Measures].[Unit Sales] -
([Measures].[Unit Sales], [Time].PrevMember))

==================================

and what is that the filter is working on
[Time].[1997].[Q4].[12]) = 4)

Please explain for understanding it better


Reply With Quote
  #4  
Old   
pras
 
Posts: n/a

Default Re: List the products whos unit sales increasing for the last 4 months - 06-28-2005 , 06:36 AM



Hi ,

I couldn't get the hang of
==================================
'Sgn([Measures].[Unit Sales] -
([Measures].[Unit Sales], [Time].PrevMember))

==================================

and what is that the filter is working on
[Time].[1997].[Q4].[12]) = 4)

Please explain for understanding it better


Reply With Quote
  #5  
Old   
Deepak Puri
 
Posts: n/a

Default Re: List the products whos unit sales increasing for the last 4 months - 06-28-2005 , 10:34 AM



From the VBA Language Reference:
Quote:
Sgn Function

Description

Returns a Variant (Integer) indicating the sign of a number.

Syntax

Sgn(number)

The required number argument can be any valid numeric expression.

Return Values

If number is
Sgn returns

Greater than zero
1

Equal to zero
0

Less than zero
–1
...
Quote:
So Sgn() returns +1 whenever current sales > prev sales. The filter
selects products for which the sum is 4 for 4 months, ie. Sgn() returns
+1 for each of last 4 periods.


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.