Forum Discussion

apuchakayala's avatar
apuchakayala
Frequent Visitor
3 years ago
Solved

How to Ignore -ve Values Only when calculating Total Average

Hi Team,

 

I have been trying to find the solution for below question, but couldn't find any posts related to it.

 

I have a scenario where I have created a measure to find the profit % of a resource.

So the Profit % can be  a+ve or -ve value.

 

Now, Profit % is added to table visual along with resource name. I want Profit % column to display both -ve and +ve values. But In the total I want the Total average value of the column to only consider +ve values.

 

Thanks in Adavance for all the help.

 

ResourceResource Profitability ( Measure)

A-20%
B4%
C-5%
D10%
Total Average

7%

 

 

  • Here is the solution I finally got;

     

    IF( ISINSCOPE( 'Table_name' [Resource] ), [Resource Profitability(measure)],

    CALCULATE( AVERAGEX('Table_name',[Resource Profitability(measure)]), FILTER('Table_name',[Resource Profitability (Measure)] = 0 || [Resource Profitability(measure)] > 0)

    ))

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi apuchakayala ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a measure. 

     

    Total Average = 
    var a=SUMX(FILTER(ALL('Table'),'Table'[Resource Profitability ( Measure)]>0),'Table'[Resource Profitability ( Measure)])
    var b=COUNTROWS(FILTER(ALL('Table'),'Table'[Resource Profitability ( Measure)]>0))
    return DIVIDE(a,b,0)

     

    (3) Then the result is as follows.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

  • apuchakayala's avatar
    apuchakayala
    Frequent Visitor

    Here is the solution I finally got;

     

    IF( ISINSCOPE( 'Table_name' [Resource] ), [Resource Profitability(measure)],

    CALCULATE( AVERAGEX('Table_name',[Resource Profitability(measure)]), FILTER('Table_name',[Resource Profitability (Measure)] = 0 || [Resource Profitability(measure)] > 0)

    ))