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

Group By Filter for Total Amounts

So I have a dataset that is full of positive and negative numbers ex:

Bill NumberCharge
1-10
120
28
2-9
2-3

 

I want to create a few measures that sum up the count and total for bills that are positive and negative. 

So positive count = 1 Bill with a $10 charge

and negative count would = 1 Bill with -4 Charge 

 

The problem is not counting bill 1 in the negatives just because it has one negative charge, since its total is positive.   

 

My measure right now look like this:

 

Sum of Bills = CALCULATE(SUM(Table[Charge]),GROUPBY(Table,Table[Bill Number]))
Grouped = CALCULATE(DISTINCTCOUNT(Table[Bill Number]),filter(Table,[Sum of Bills] > 0))
 
This gets me close but I think I am missing one piece to the 2nd query. Any help would be appreciated.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

 

The following measures are for your reference.

Sum of Bills = CALCULATE(SUM('Table'[Charge]), ALLEXCEPT('Table', 'Table'[Bill Number]))

 

Grouped = COUNTX(SUMMARIZE(FILTER('Table', [Sum of Bills] > 0), 'Table'[Bill Number]), [Bill Number])

 

Output:

vxuxinyimsft_0-1720748807166.png

 

Best Regards,
Yulia Xu

 

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

2 REPLIES 2
Anonymous
Not applicable

This works perfectly, thank you!

Anonymous
Not applicable

Hi @Anonymous 

 

The following measures are for your reference.

Sum of Bills = CALCULATE(SUM('Table'[Charge]), ALLEXCEPT('Table', 'Table'[Bill Number]))

 

Grouped = COUNTX(SUMMARIZE(FILTER('Table', [Sum of Bills] > 0), 'Table'[Bill Number]), [Bill Number])

 

Output:

vxuxinyimsft_0-1720748807166.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.