sql - intersect and topcount and order function in MDX query -
i use sql server 2008 r2 , use ssrs , use adventure work
database.
i write mdx query 10 city in top ten in both years 2003 , 2004.
with set [best cities in cy 2003/2004] intersect( order( topcount( [customer].[customer geography].[city], 10, ( [measures].[internet sales amount], [date].[calendar].[calendar year].[cy 2003] ) ), [measures].[internet sales amount], bdesc ), order( topcount( [customer].[customer geography].[city], 10, ( [measures].[internet sales amount], [date].[calendar].[calendar year].[cy 2004] ) ), [measures].[internet sales amount], bdesc ) ) select [measures].[internet sales amount] on columns, [best cities in cy 2003/2004] on rows [adventure works] { [date].[calendar].[calendar year].[cy 2003], [date].[calendar].[calendar year].[cy 2004] }
but want list of cities internet sales has decreased 35% compared previous year , cities among top 10 cities in same year well.
how can result?
you use filter
this:
with set [best cities in cy 2003/2004] filter( intersect( topcount( [customer].[customer geography].[city], 10, ( [measures].[internet sales amount], [date].[calendar].[calendar year].[cy 2003] ) ), topcount( [customer].[customer geography].[city], 10, ( [measures].[internet sales amount], [date].[calendar].[calendar year].[cy 2004] ) ) ), ([measures].[internet sales amount], [date].[calendar].[calendar year].[cy 2004]) / ([measures].[internet sales amount], [date].[calendar].[calendar year].[cy 2003]) - 1.0 < -0.35 ) select [measures].[internet sales amount] on columns, [best cities in cy 2003/2004] on rows [adventure works] { [date].[calendar].[calendar year].[cy 2003], [date].[calendar].[calendar year].[cy 2004] }
Comments
Post a Comment