Forum Discussion

Rebender's avatar
Rebender
Frequent Visitor
7 years ago
Solved

Calculate Average with Filter

Good afternoon, I am trying to create an average using a filter.  In my screen shot below, you can see that under the Attribute column there are two different values.  I want to be able to sum up th...
  • v-lili6-msft's avatar
    7 years ago

    HI, Rebender

    You may try to this formula to create a measure as below:

    Measure = 
    DIVIDE (
        CALCULATE ( SUM ( 'Table'[Process Hours Entry to] ) ),
        CALCULATE (
            COUNTA ( 'Table'[Attribute] ),
            'Table'[Process Hours Entry to] <> 0
        ),
        0
    )

    or use this formula to create a column

    Column = DIVIDE (
        CALCULATE ( SUM ( 'Table'[Process Hours Entry to] ),FILTER('Table','Table'[Attribute]=EARLIER('Table'[Attribute]) )),
        CALCULATE (
            COUNTA ( 'Table'[Attribute] ),FILTER('Table','Table'[Attribute]=EARLIER('Table'[Attribute])&&
            'Table'[Process Hours Entry to] <> 0)
        ),
        0
    )

    Result:

    measurecolumn

    here is pbix, please try it.

    https://www.dropbox.com/s/rgvy7m8w1l15we6/Calculate%20Average%20with%20Filter.pbix?dl=0

     

    Best Regards,

    Lin