我有一个多维数据集,其中包含有关访问具有IP地址和国家/地区的网站的信息。
我想检索每个国家/地区的唯一IP地址数,如下面的表格所示。
+-------------+----------+
| country | count IP |
+-------------+----------+
| germany | 2 |
| netherlands | 3 |
+-------------+----------+
但到目前为止我想出的就是:
+-------------+---------------+--------+
| country | IP | visits |
+-------------+---------------+--------+
| germany | 65.49.14.152 | 5 |
| | 66.55.144.187 | 12 |
| netherlands | 93.114.46.11 | 2 |
| | 93.115.94.85 | 5 |
| | 141.105.1.7 | 1 |
+-------------+---------------+--------+
由此查询生成:
SELECT
NON EMPTY
{Hierarchize({[Measures].[Visits]})} ON COLUMNS
,NON EMPTY
CrossJoin
(
[Geografy.Localizacion].[Country].MEMBERS
,[RemoteClient].[IP].MEMBERS
) ON ROWS
FROM [VisitsCube];
如何修改此查询以生成第一个表格中的结果?
答案 0 :(得分:0)
创建一个计算成员,该成员将保存每个唯一IP的计数。然后从行轴移除[RemoteClient].[IP].Members
。
WITH MEMBER Measures.[Count IP] AS
SUM(Distinct(EXISTING [RemoteClient].[IP].Members), [Measures].[Visits])
SELECT NON EMPTY [Geografy.Localizacion].[Country].Members ON 1,
NON EMPTY Measures.[Count IP] ON 0
FROM [VisitsCube]
答案 1 :(得分:0)
在AdvWrks
我测试了这种方法:
WITH
MEMBER [Measures].[CountX] AS
Sum
(
[Customer].[Customer Geography].[City]
,IIF
(
NOT isempty([Measures].[Internet Sales Amount])
,1
,null
)
)
SELECT
{[Measures].[CountX]} ON 0
,NON EMPTY
[Product].[Product Categories].[Category]
ON 1
FROM [Adventure Works]
WHERE
[Geography].[Geography].[Country].&[Canada];
它给出了每种产品类别的互联网销售额的城市数量:
根据你的情况我认为是这样的:
WITH
MEMBER [Measures].[CountX] AS
Sum
(
[RemoteClient].[IP].MEMBERS
,IIF
(
NOT isempty([Measures].[Visits])
,1
,null
)
)
SELECT
NON EMPTY
[Geografy.Localizacion].[Country].MEMBERS ON 1
,NON EMPTY
[Measures].[CountX] ON 0
FROM [VisitsCube];