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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DAX to countrow if sum condition is met

Hi, 

 

Trying to work out the DAX measure to count the rows if the sum of the amount is greater than 0 per ClientID, but to no avail. 

 

Data is as follows:

ClientIDAmount
10
110
20
3100

 

Each row is a meeting, and I need to count the number of meetings in the case that the sum of the amount per Client ID is >0. 

 

So, figure for above table would be 3 meetings.

 

What would be the best way to achieve this?

 

Many thanks!

 

Matt

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

You could do a SUMMARIZE by Client ID and then do a simple CALCULATE, COUNT, FILTER [Amount] > 0



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

You could do a SUMMARIZE by Client ID and then do a simple CALCULATE, COUNT, FILTER [Amount] > 0



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks for the pointer @Greg_Deckler

 

I've created a table with summarize and then counted the rows in the original table, filtering by those clientID with amounts >0. 

 

Table = SUMMARIZE(Sheet1;Sheet1[ClientID];"Test";sum(Sheet1[Amount]))

 

Measure 4 = CALCULATE(COUNTROWS(Sheet1); filter('Table';'Table'[Test]>0))

 

I presume using an intermediary table will impact on the size of the data model? Is that the best way of doing it or can I do it all in one measure without the need for the additional table?

 

Thanks for your time and assistance.

 

Matt

 

 

You should be able to do that in a single measure, something like:

 

Measure 4 = 

VAR mytable = SUMMARIZE(Sheet1;Sheet1[ClientID];"Test";sum(Sheet1[Amount]))
 
RETURN CALCULATE(COUNTROWS(mytable); filter('mytable';[Test]>0))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Perfect, thanks. That worked when I based the count on the original table (Sheet1) in the return calculate. 

 

 

Final Measure = 
   var SummaryTable = SUMMARIZE(Sheet1;Sheet1[ClientID]; "Test"; sum(Sheet1[Amount]))

RETURN

  CALCULATE(COUNTROWS(Sheet1); filter(SummaryTable; [Test] > 0))

 

 

Once again thanks for your help.

 

Matt

Ah, that makes sense, glad you got it worked out!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors