我一直在考虑将一些深入查询从 T-SQL 转移到 DAX 以提高性能。我并没有真正将 DAX 用作一种查询语言,并且一直在努力寻找可以让我转换以下简单 SQL 查询的示例。我设法找到了过滤表和连接表的示例,但没有在 DAX 中将这些操作组合在一起的真实示例。
我要转换的以下查询包含联接和过滤表。是否可以在 DAX 中重写它?
我担心的另一个问题是 fp.[Fact Product Id] 列具有非常高的基数,实际上是退化维度。当我尝试在 MDX 中重写它以针对表格多维数据集运行时,查询需要很长时间并最终因内存不足错误而崩溃。DAX 查询会遇到同样的问题吗?
Select dcpss.[Customer Product Status Rollup],
dcpss.[Customer Product Status],
dc.[Customer Id],
dc.[Customer Name],
dcps.[Customer Product Source],
dp.Country,
dp.[Product Number],
dp.[Product Name],
drbi.[Incident Number] As [Renewed By Order Number],
drbi.[Incident Status] As [Renewed By Order Status],
fp.[Fact Product Id] As [Product Id],
fp.[Product Count],
ded.[Date] As [Expiry Date]
From [rpt].[Fact Product] fp
Inner Join [rpt].[Active Dim Product] dp On dp.[Historical Product Key] = fp.[Product Key]
Inner Join [rpt].[Active Dim Customer] dc On dc.[Historical Customer Key] = fp.[Product Customer Key]
Inner Join [rpt].[Dim Expiry Date] ded On ded.[Expiry Date Key] = fp.[Expiry Date Key]
Inner Join [rpt].[Dim Customer Product Source] dcps On dcps.[Customer Product Source Key] = fp.[Customer Product Source Key]
Inner Join [rpt].[Dim Customer Product Status] dcpss On dcpss.[Customer Product Status Key] = fp.[Customer Product Status Key]
Inner Join [rpt].[Dim Renewed By Incident] drbi On drbi.[Renewed By Incident Key] = fp.[Renewed By Incident Key]
Where ded.[Month of Year Name] = 'June'
And ded.[Year Name] = 2015
And (ded.[Day of Month] = @DayOfMonth Or @DayOfMonth Is Null)
And dcps.[Customer Product Source] <> 'Free PP Product'
And dc.[Payment Type] <> 'Free'
And dp.Country = 'AU'
And dp.[Sales Type] <> 'Trial';