Hey All,
I wrote this query to work in ssms. But now I have to run the same logic in from Cube. But not able to implement this logic in MDX, Could anyone suggest the way to convert it. Here I used self join to compare the variance.
select m3.* from facts m3,(
select count(*) cou,m1.TName tname1,m1.pDate,m2.TName tname2 from facts m1,facts m2
where m1.DateKey=m2.DateKey and ((m1.variance-m2.variance) between -5 and 5) and
m1.tname='c1' and m2.TName!='c1'
group by m1.TName,m1.pDate,m2.TName
having COUNT(*)>30
) as t1
where m3.TName=t1.tname2 and m3.pDate=t1.pDate
order by tname1
union
select * from facts where tagname='c1'
order by TagName