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

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

Reply
Wkeith
Helper II
Helper II

DistinctCount Based with criteria based on a Sum of Values for a Quarter

Basically I want to count the number of distinct accounts that have sales greater than 0 for a quarter. The problem is that some accounts have negative sales for a quarter. Each account has multiple lines of data per quater for different transactions that have taken place. This is where I'm running into the issue. It is counting the lines that are positive as being greater than 0 and therefore getting added to my count total even though if you summed up ALL the lines for that quarter they would be less than 0. Example:

 

Account 1 - 1/1/2019 - $100

Account 1 - 1/3/2019 - -$200

 

So the total for this quater would be -$100 and therefore I don't want to count it but since one of the lines has positive revenue (the first line) it is counting it.

 

Also, I am filtering this measure that I have created by quarter in my dashboard so that it only shows the quarters that I want. 

 

Current forumla I'm using (ignore the other critiera, the last part is what I am focusing on): 

 

CVDistrictCount = CALCULATE(DISTINCTCOUNT(FactSales[CV DISTRICT]),FactSales,FactSales[CV DISTRICT]<>"*Accounting Adj.", FactSales[CV DISTRICT]<>"*OUS Accounting Adj.", FactSales[CV DISTRICT]<>"Not Applicable",FactSales[CV DISTRICT]<>"No Agent Listed", FactSales[Revenue]>0)
 
 
I'll be by the computer all day if you need any more info or clarification on my end. Thanks for the help in advance! 
1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

Hi @Wkeith ,

Assume that we have a table like below:

PBIDesktop_J1UL1BFg2V.png

Then we can create a measure like below:

Measure =
VAR temptable =
    SUMMARIZE (
        Table1,
        Table1[account],
        Table1[date].[Quarter],
        "Judge", SUM ( Table1[value] )
    )
RETURN
    CALCULATE ( COUNTROWS ( FILTER ( temptable, [Judge] > 0 ) ) )

The result will like below:

PBIDesktop_6jjDvq3drO.png

Best Regards,

Teige

View solution in original post

2 REPLIES 2
TeigeGao
Solution Sage
Solution Sage

Hi @Wkeith ,

Assume that we have a table like below:

PBIDesktop_J1UL1BFg2V.png

Then we can create a measure like below:

Measure =
VAR temptable =
    SUMMARIZE (
        Table1,
        Table1[account],
        Table1[date].[Quarter],
        "Judge", SUM ( Table1[value] )
    )
RETURN
    CALCULATE ( COUNTROWS ( FILTER ( temptable, [Judge] > 0 ) ) )

The result will like below:

PBIDesktop_6jjDvq3drO.png

Best Regards,

Teige

Wkeith
Helper II
Helper II

Basically, to put this in simpler terms, is there a way to Distincally Count a range of values based on a criteria that sums up their revenue based on all their transactions not just individual transactions. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.