【问题标题】:DAX for calculated column that shows relative value compared to the parent in a tabular model [closed]计算列的 DAX,显示与表格模型中的父级相比的相对值 [关闭]
【发布时间】:2020-10-23 07:08:51
【问题描述】:

我有一个维度表

ProductID Product_Name 子类别类别

有一个层次结构 Product-Name-> Sub-Category -> Category

我还有一个包含销售数据和 ProductID 的事实表。

我想要一个计算列,显示产品在所选度量的子类别中的份额。例如“产品名称的度量除以子类别中的度量”,列中的值为 5%。

如何在表格模式中解决这个问题?

【问题讨论】:

    标签: dax hierarchy business-intelligence ssas-tabular


    【解决方案1】:

    试试这个:

    Calc% = 
    var __SubCategorySUM = CALCULATE(SUM([Sales]), FILTER(ALL('YourTable'),  
    SELECTEDVALUE('YourTable'[Sub-Category]) = 'YourTable'[Sub-Category]))
    var __SumProd = CALCULATE(SUM[Sales])
    
    return
    
    DIVIDE(__SumProd , __SubCategorySUM )
    

    【讨论】:

    • 有效!!非常感谢!唯一错误的是,您使用 , 而不是 ;在第二行。在 FILTER 和 SELECTEDVALUE 之前应该是 ;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-23
    • 1970-01-01
    • 1970-01-01
    • 2014-11-01
    • 2018-08-03
    • 1970-01-01
    • 2011-10-03
    相关资源
    最近更新 更多