Search code examples
powerbidata-analysispowerbi-desktop

How to divide a value in a Cell with the Sum of an entire column in Power BI


I want to divide a cell with the sum of the total value of the another cell in Power BI.

I wrote the formulae for the code but unfortunately this is not working.

Can someone help me out.

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

The excel formulae for this calculation is given below:

enter image description here

The calculation here is (2500/22500)*100.

The error I am getting is: The SUM function only accepts a column reference as the argument number 1.

Attached the numbers used for calculation:

enter image description here


Solution

  • You use ALLSELECTED - see https://learn.microsoft.com/en-us/dax/allselected-function-dax

    Example:

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

    Note also the use of DIVIDE: https://learn.microsoft.com/en-us/dax/best-practices/dax-divide-function-operator