开发者

Business intelligence - Can't find the value I'm looking for

I'm setting up a SSAS project for our websites but I can't managed to find the good value whereas it's quite simple in plain SQL query.

Here's my setup : I have a datawarehouse filled with user connection fact on my sites. And so I have a Member dimension and a date dimension. Heres's the KPI I'm loking for : "For how many average days a user is coming to see our site".

Let's take an example :

Member    Day
a       开发者_如何转开发  1
a         1
a         2
b         2
a         4
a         5
b         5
a         6

In this case the KPI should give 3,5 (a=5, b=2). In plain SQL I would have done an average on a group by on a group by (it's the first request I've got in mind, maybe there's a better one).

But as soon as I try to assemble dimension and facts together I can't find the right measure.

Am I looking for the wrong thing ? Should I abandon my SQL way of thinking ? How would you do to get the value I need ?


I understand now! It was just an internationalisation problem. To me 3,5 means the numbers 3 and 5, I'd write it as 3.5 :)

SELECT
  AVG(CountOfDay) As AverageDays
FROM
  (SELECT Member, COUNT(DISTINCT Day) CountOfDay FROM YourTable GROUP BY Member) AS UniqueDaysByMember

Really you don't need "Member" in the sub-query's SELECT. It just makes it "mean" something to me, so I don't get confused if I come back and look at the code later!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜