Forum Discussion

TD21's avatar
TD21
Helper II
5 years ago
Solved

Using Measure in Calculation Not Returning Expected Results.

I have a measure called THRESHOLD, where [THRESHOLD] = AVERAGE ( [INVOICE AMOUNT] ) - 12500. The currently value of THRESHOLD is 6000.   If I create a column called TEST1, where TEST1 = IF ( [INVOI...
  • Greg_Deckler's avatar
    5 years ago

    TD21 - It is generally a bad idea to use a measure in a calculated column. There are 2 reasons why

    1. Row context

    2. Calculated columns are not dynamic

     

    Now, in your case the Row context is the problem. Let's see, what is the AVERAGE of a singe row in your INVOICE AMOUNT table? Hmm, that would be the value for [INVOICE AMOUNT] in that row. The AVERAGE of a single value is the value. Hence, that row's [INVOICE AMOUNT] can never be less than itself and definitely won't be less than itself minus some number and hence why you get NO for everything.

     

    Now, in your case, if you are not worried about 2, then you could get around this by changing your THRESHOLD formula to:

     

    [THRESHOLD] = CALCULATE(AVERAGE ( [INVOICE AMOUNT] ),ALL('Table')) - 12500
    
    or
    
    [THRESHOLD] = AVERAGEX ( ALL('Table'),[INVOICE AMOUNT] ) - 12500

     

    Second formula edited thanks to CNENFRNL catching my copy and paste error!