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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
mcomsto
Helper I
Helper I

CountX with filtered measures and dynamic slicers

Hi,  I have spent way to much time trying to figure this one out and it seems like it should be easy, but I'm no expert.  I am trying to apply a countx measure with a filter, but it is giving me the wrong count.  I have attach a mock up pbix file.  If you can provide an insight, it would be greatly appreciated.

 

The measures in question are the Q1 Above Zero and the Q1 Equals Zero.

 

https://www.dropbox.com/s/gbfb8nmwyp2bkrp/mockupforcountxissue.pbix?dl=0

 

2020-02-05_15-46-22.png

 

1 ACCEPTED SOLUTION
edhans
Super User
Super User

I don't think the measure is really the problem, it is the underlying data. Thanks for the PBIX file - very helpful.

 

8 is the right answer, because COUNTX is looking at the rows in the actual table, and there are 8 that are zero.

20200205 13_09_20-mockupforcountxissue - Power BI Desktop.png

 

The below will tell you the unique count of customers that are zero, but it still isn't showing you what is in your summary table. It just eliminates the duplicate customer numbers.

 

Q1 Equals Zero = 
CALCULATE(
    COUNTROWS(
        DISTINCT(Sheet1[Customer])
    ),
    FILTER(
        Sheet1,
        [Comp Q1 Form Score Diff] = 0
    )
)

  I think what you want is this, which returns 2, the number of 0's in the Q1 column:

Customer Totals are Zero =
COUNTROWS(
    FILTER(
        SUMMARIZECOLUMNS(
            Sheet1[Customer],
            "Total", SUM( Sheet1[AllData.Q1 Score] )
        ),
        [Total] = 0
    )
)


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

1 REPLY 1
edhans
Super User
Super User

I don't think the measure is really the problem, it is the underlying data. Thanks for the PBIX file - very helpful.

 

8 is the right answer, because COUNTX is looking at the rows in the actual table, and there are 8 that are zero.

20200205 13_09_20-mockupforcountxissue - Power BI Desktop.png

 

The below will tell you the unique count of customers that are zero, but it still isn't showing you what is in your summary table. It just eliminates the duplicate customer numbers.

 

Q1 Equals Zero = 
CALCULATE(
    COUNTROWS(
        DISTINCT(Sheet1[Customer])
    ),
    FILTER(
        Sheet1,
        [Comp Q1 Form Score Diff] = 0
    )
)

  I think what you want is this, which returns 2, the number of 0's in the Q1 column:

Customer Totals are Zero =
COUNTROWS(
    FILTER(
        SUMMARIZECOLUMNS(
            Sheet1[Customer],
            "Total", SUM( Sheet1[AllData.Q1 Score] )
        ),
        [Total] = 0
    )
)


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors