Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Count based on measure outcome

Hey guys I have a measure that substracts costs from income:

Profit = SUM(table1[Total budget]) - sum(table2[Costs])

Now, in a new measure, I want to count the amount of rows (ID's) that are profitable

Id's profitable = CALCULATE(DISTINCTCOUNT('Table1'[ID]); FILTER('Measures'; 'Measures'[Profit] > 0)

This did not seem to work: The measure counts the total of present ID's, rather than taking into account ID's that have profit > 0. Any clue what to do?
  • Anonymous 

     

    Try this one

     

    Measure =
    COUNTROWS ( FILTER ( VALUES ( 'Table1'[ID] ), [Profit] > 0 ) )
    
  • Hi Anonymous ,

     

    Not sure if you'd like to get this one:

    Profit = CALCULATE(SUM(Table1[Total budget])-SUM(Table2[Costs]),FILTER(Table2,[ID]=MAX(Table1[ID])))
    Measure = 
    CALCULATE(DISTINCTCOUNT('Table1'[ID]),FILTER(Table1,[Profit]>0))

     

3 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Icon for Community Champion rankCommunity Champion

    Anonymous 

     

    Try this one

     

    Measure =
    COUNTROWS ( FILTER ( VALUES ( 'Table1'[ID] ), [Profit] > 0 ) )
    
  • v-diye-msft's avatar
    v-diye-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Not sure if you'd like to get this one:

    Profit = CALCULATE(SUM(Table1[Total budget])-SUM(Table2[Costs]),FILTER(Table2,[ID]=MAX(Table1[ID])))
    Measure = 
    CALCULATE(DISTINCTCOUNT('Table1'[ID]),FILTER(Table1,[Profit]>0))

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the replies guys! The first solution worked perfectly (countrows).