Forum Discussion

ROBERTOCMRNO's avatar
ROBERTOCMRNO
Frequent Visitor
9 years ago
Solved

Weighed Average DAX Expression

I need a help...

I want to do this expressin dax, but I´m with problems in the days.

Someone help me?

Thank you.

  • v-ljerr-msft's avatar
    v-ljerr-msft
    9 years ago

    Hi ROBERTOCMRNO,

     

    Could you post your all table structures with some sample data in this case? Without knowing that we can only guess and offer possible suggestions.:smileyhappy:

     

    Normally, the DAX expression for Weighted Average should be similar like below.

    [Average Med Age Weighted by Pop]=
    SUMX(Zips, Zips[TTL Pop] * Zips[Med Age]) / [Total Population]

    And

    WAC = SUMX ( 'Analytics_SourceDat', [Net_Active_Balance] * [INTEREST_RATE] )
        / SUMX ( 'Analytics_SourceDat', [Net_Active_Balance] )

    In addition, here is a similar thread, and here is a good article about Weighted Averages(DAX) for your reference.

     

    Regards

6 Replies

  • austinsense's avatar
    austinsense
    Icon for Impactful Individual rankImpactful Individual

    I'm getting a headache reading that Excel formula . Weighted average is pretty straigtforward in DAX.  The basic pattern looks like this ...

     

    Weighted Average = SUM(one number) / SUM(other number)

    You would write that as a new measure.  This is even better because it deals with the divide by zero.

     

    Weighted Average = DIVIDE( SUM(one number), SUM(other number) )

    Hope that helps.  The trick is to stop thinking in terms of cells and to start thinking in terms of columns.

    • ROBERTOCMRNO's avatar
      ROBERTOCMRNO
      Frequent Visitor

      Thank you for reply,

      I tried this, but does not work...

      The result of column MetaDiariaPonderada must be same the column Total.

      The value of column MetaDiariaPonderada must be increase by the Column Dia.

      • v-ljerr-msft's avatar
        v-ljerr-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi ROBERTOCMRNO,

         

        Could you post your all table structures with some sample data in this case? Without knowing that we can only guess and offer possible suggestions.:smileyhappy:

         

        Normally, the DAX expression for Weighted Average should be similar like below.

        [Average Med Age Weighted by Pop]=
        SUMX(Zips, Zips[TTL Pop] * Zips[Med Age]) / [Total Population]

        And

        WAC = SUMX ( 'Analytics_SourceDat', [Net_Active_Balance] * [INTEREST_RATE] )
            / SUMX ( 'Analytics_SourceDat', [Net_Active_Balance] )

        In addition, here is a similar thread, and here is a good article about Weighted Averages(DAX) for your reference.

         

        Regards