代码之家  ›  专栏  ›  技术社区  ›  Mr Pool

如何在Power BI中将单元格中的值除以整列的总和

  •  0
  • Mr Pool  · 技术社区  · 2 年前

    我想用Power BI中另一个单元格的总值除以一个单元格。

    我为代码编写了公式,但不幸的是,这不起作用。

    有人能帮我吗。

    Agg Forecast Accuuracy = IFERROR(([Weightage Selection]/SUM([Weightage Selection])*[Forecast Accuracy]),0)
    

    该计算的excel公式如下所示:

    enter image description here

    此处的计算为(2500/22500)*100。

    我得到的错误是: The SUM function only accepts a column reference as the argument number 1.

    附上用于计算的数字:

    enter image description here

    1 回复  |  直到 2 年前
        1
  •  1
  •   Sam Nseir    2 年前

    您使用 ALLSELECTED -请参阅 https://learn.microsoft.com/en-us/dax/allselected-function-dax

    例子:

    Agg Forecast Accuuracy =
      DIVIDE(
        [Weightage Selection],
        SUMX(ALLSELECTED('Sheet1'), [Weightage Selection])
      ) * [Forecast Accuracy]
    

    还请注意的使用 DIVIDE : https://learn.microsoft.com/en-us/dax/best-practices/dax-divide-function-operator