Forum Discussion

MAAbdullah47's avatar
MAAbdullah47
Helper V
9 years ago
Solved

Quick Measure percentage difference gives wrong value

Dear All,   Thank you for your support, I need your advice on the following issue:   I want to calculate the average price difference between car model year and the previous one, I created a quic...
  • v-ljerr-msft's avatar
    v-ljerr-msft
    9 years ago

    Hi MAAbdullah47,

     

    I just verified that the formula works all fine with your shared sample data.

     

    Avg price for 2016 = 219270 and for 2015 = 219058 so the equation should be

     

    Diff = (219270 / 219058 ) - 1 = 0.1 %

     

     

    Regards

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

    Hi MAAbdullah47,

     

    Based on my test, the formula below should work. :smileyhappy:

    Diff = 
    VAR currentYear =
        MAX ( 'saudisale_c'[d_year] )
    VAR avgPricePY =
        CALCULATE (
            AVERAGE ( 'saudisale_c'[d_price] ),
            FILTER ( ALL(saudisale_c[d_year]), 'saudisale_c'[d_year] = currentYear - 1 )
        )
    RETURN
        DIVIDE ( AVERAGE ( 'saudisale_c'[d_price] ) - avgPricePY, avgPricePY )

     

    Regards