Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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?
2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this one

 

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

Regards
Zubair

Please try my custom visuals

View solution in original post

v-diye-msft
Community Support
Community 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))

007.PNG

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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

v-diye-msft
Community Support
Community 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))

007.PNG

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this one

 

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

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.