简单的DAX查询总结和计算

时间:2013-12-26 14:44:06

标签: ssas business-intelligence tabular dax

我有这种格式的SSAS表格模型:

enter image description here

我需要一个SSAS DAX查询,它输出以下格式:

enter image description here

有谁知道如何做到这一点?

我将在SSRS报告中使用它。

1 个答案:

答案 0 :(得分:0)

很难给出答案,你可以复制/粘贴,因为我不知道你的模型或表格是什么样的。您应该能够调整下面的度量和查询以适合您的模型。

[ProductSales] := 
SUMX ( Sales, Sales[Quantity] * Sales[Price] )

[SalesMTD] :=
CALCULATE ( [ProductSales], DATESMTD ( DateTable[DateKey] ) )

[SalesYTD] :=
CALCULATE ( [ProductSales], DATESYTD ( DateTable[DateKey] ) )

[SalesMTDPrevYear] :=
CALCULATE (
    [ProductSales],
    SAMEPERIODLASTYEAR ( DATESMTD ( DateTable[DateKey] ) )
)

[SalesYTDPrevYear] :=
CALCULATE (
    [ProductSales],
    SAMEPERIODLASTYEAR ( DATESYTD ( DateTable[DateKey] ) )
)

将您的信息提取到SSRS(我假设您知道如何进入数据集创建屏幕):

EVALUATE
SUMMARIZE ( 
    Locations[Continent], 
    Locations[Country], 
    Locations[City], 
    Products[ProductName], 
    "Month Sales (This Year)", [SalesMTD],
    "Month Sales (Last year)", [SalesMTDPrevYear], 
    "YTD Sales (This Year)", [SalesYTD], 
    "YTD Sales (Last year)", [SalesYTDPrevYear]
)