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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
tulasik
Frequent Visitor

Distinct Count with Filter

Hi Everyone,

I am trying to calculate distinct count with filters. I have used the formula: 

SoldOC = CALCULATE(DISTINCTCOUNT('Dimension - DMA Configs'[Order Code]),FILTER('Measures - Revenue','Measures - Revenue'[Revenue Total]>=0))
However it seems to count the ones without revenue as well.

tulasik_0-1594912792574.png

Regards,

Tulasi

3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @tulasik ,

 

Is the 'Measures - Revenue'[Revenue Total] a measure? We must analyze the formula of this measure if we want to find the error.

The easiest way is to change this measure to the calculated column in 'Dimension - DMA Configs’ table.

 

Best regards,
Lionel Chen

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

 

amitchandak
Super User
Super User

@tulasik , Try like

SoldOC = CALCULATE(DISTINCTCOUNT('Dimension - DMA Configs'[Order Code]),FILTER('Measures - Revenue',coalesce('Measures - Revenue'[Revenue Total],0)>=0))

 

Hope Revenue Total is column

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
DataZoe
Microsoft Employee
Microsoft Employee

@tulasik You could try this adjustment to your measure:

SoldOC =
CALCULATE (
    DISTINCTCOUNT ( 'Dimension - DMA Configs'[Order Code] ),
    FILTER (
        'Measures - Revenue',
        'Measures - Revenue'[Revenue Total] >= 0
            && ISBLANK ( 'Measures - Revenue'[Revenue Total] ) = FALSE
    )
)

 

or this one:

 

SoldOC =
IF (
    ISBLANK ( 'Measures - Revenue'[Revenue Total] ),
    BLANK (),
    CALCULATE (
        DISTINCTCOUNT ( 'Dimension - DMA Configs'[Order Code] ),
        FILTER ( 'Measures - Revenue', 'Measures - Revenue'[Revenue Total] >= 0 )
    )
)

 

Hope it helps!

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.