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

Exclude rows where Group By amount is zero

Hi there,

I need to write a DAX in my report which will DistinctCount DocNo only for the records where Grouped value (Amount) is not zero. See the following scenario.

MyTables has several records and DistictCount will be 4 (which is not a desired result).

MyGroupTable (group by DocNo) has 4 records and DistictCount will only count records where amount is not zero, so result will be 2.

Any help will be highly appreciated.

 

Count non-zeros.PNG

 

Let me know for more details.

1 ACCEPTED SOLUTION

I was not sure whether you wanted a calculated table or a calculated measure.

 

There are more than a few ways in writing measures. However, without knowing the data model,  all of them might be suitable for your model, or perhaps only one of them might be suitable.

 

https://www.dropbox.com/s/75rgey6rqntyt7k/mughalia.pbix?dl=0 

 

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Picture1.png

 

Group Table =
SUMMARIZECOLUMNS (
'Table'[DocNo],
FILTER ( VALUES ( 'Table'[DocNo] ), CALCULATE ( SUM ( 'Table'[Amount] ) <> 0 ) ),
"@Amount", SUM ( 'Table'[Amount] )
)

 

https://www.dropbox.com/s/75rgey6rqntyt7k/mughalia.pbix?dl=0 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hi @Jihwan_Kim 

Thank you for your reply.

I guess we are almost there. The DAX is returning two rows and two columns. The DAX should return only 2 in this instance, because there are only two records with non-zero amount.

Could you tweak the DAX and advise please?

Thank you

I was not sure whether you wanted a calculated table or a calculated measure.

 

There are more than a few ways in writing measures. However, without knowing the data model,  all of them might be suitable for your model, or perhaps only one of them might be suitable.

 

https://www.dropbox.com/s/75rgey6rqntyt7k/mughalia.pbix?dl=0 

 

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@Anonymous , Try measure like

 

Measure =
var _sum = sum(Table[Amount])
return
calculate(if(_sum=0, blank(), _sum))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you @amitchandak 

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