Forum Discussion

Cyrilbrd's avatar
Cyrilbrd
Helper IV
3 years ago
Solved

sumif or equivalent

I am trying to get the percentage of a value in a column based on one condition. In excel I would use something along SUMIF or SUMIFS to get the value I want and would divide it by the total without...
  • v-jianboli-msft's avatar
    3 years ago

    Hi Cyrilbrd ,

     

    Here is my example:

    Please try:

    Measure for value 1 = 
    var _a = SUM('Table'[Value1])
    var _b = CALCULATE(SUM('Table'[Value1]),REMOVEFILTERS('Table'[Code]))
    return DIVIDE(_a,_b)
    
    Measure for value 2 = 
    var _a = SUM('Table'[Value2])
    var _b = CALCULATE(SUM('Table'[Value2]),REMOVEFILTERS('Table'[Code]))
    return DIVIDE(_a,_b)

    Output:

     

     

    Best Regards,

    Jianbo Li

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