Forum Discussion

Sudharsanan's avatar
Sudharsanan
Helper III
4 years ago
Solved

Weighted Avg calculation

Hi friends,

 

I need help in calculating weighted avg for the below data using DAX. can someone help me?

 

Logic: (Sum of CY sales)/((sum of PY sales)/(sum of PY qty))*sum of Cyqty)))-1 

 

CustprodCySaleCyQtyPYSalePY Qty
1A1,193155267
2B1,16537772
3C1,02845963
4A80251,38910
5B79469228
6C76741711
7A71784,30348
8B49211,3503
9C45281934
10A44552293
11B40851,18316
12C37632422
13A35521,4208
14B29532703
15C23515713
16A215101,02250
17B16321,31118
18C119559031
19A785413
20B633412
21C6111022
22A4111545
23B291512
  • Sudharsanan , Assuming all are columns

     

    Divide(Sum(Table[CY sales]), Sumx(Table, Divide([PY sales],[PY qty]) * Table[Cyqty]) ) -1

8 Replies

  • Sudharsanan , Assuming all are columns

     

    Divide(Sum(Table[CY sales]), Sumx(Table, Divide([PY sales],[PY qty]) * Table[Cyqty]) ) -1

    • Sudharsanan's avatar
      Sudharsanan
      Helper III

      Hi Fowmy 

      Hope this helps..

       

      avg Price = (pysale/pyqty)*cyqty.

       

      i am able to get the anwer correct for individual line but as a overall i am not getting it.

      • Fowmy's avatar
        Fowmy
        Super User

        Sudharsanan 
        The measure provided by amitchandak  should work,

        W AVG = 
        
        DIVIDE(
            SUM(Table2[CySale]),
            SUMX(
                TABLE2,
                DIVIDE( Table2[PYSale] , Table2[PY Qty] ) * Table2[CyQty] 
            )
        )-1