Search code examples
filtersumpowerbidaxmeasure

summation of same values once for each id


How can I define a measure to calculate the same values for each id once for summation in Power BI?

for example, in this picture sum of num ( sum(num) )should be: 5

pic

I used the code below but it returns a summation of all numbers and its result for this example is 11 instead of 5!

Measure = (CALCULATE(SUM('table1'[num]) , ALLEXCEPT('table1','table1'[order_id])))

Solution

  • First, try to calculate a virtual table that contains only rows that match your condition, then you can easily countrows and display them in CARD.

    CountOF = 
    
    var __temp = CALCULATETABLE(VALUES(Sheet2[user_id]), Sheet2[num] > 0)
    
    return 
    
    CALCULATE( COUNTROWS(__temp))
    

    enter image description here