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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
A_Scott
Frequent Visitor

DISTINCTCOUNT with Multiple Filters Not Returning Correct Count

I am trying to count how many Division-Store have zero MEAT SAWS inpsections. Each store may have a different number of saws they are required to inspect once a day. My DAX calculation keeps returning the count of meat saws with zero inspections, not the count of stores.

Here is my DAX:

Stores with Zero Meat Saw Inspections = IF([Meat Saw Count]=0,"N/A",
    CALCULATE(
    DISTINCTCOUNT('Equip IDs'[Division-Store]),
    FILTER('Equip IDs','Equip IDs'[Equipment Product Type Descr]="MEAT SAWS"),
    FILTER('Equip IDs', [Completed Meat Saw Inspections] = 0)))
1 ACCEPTED SOLUTION

Hi @A_Scott ,

You can update the formula of measure [Stores with Zero Meat Saw Inspections] as below and check if it can return the expected result...

Stores with Zero Meat Saw Inspections =
IF (
    [Meat Saw Count] = 0,
    BLANK (),
    CALCULATE (
        DISTINCTCOUNT ( 'Equip IDs'[Division-Store] ),
        FILTER (
            'Equip IDs',
            'Equip IDs'[Equipment Product Type Descr] = "MEAT SAWS"
                && [Completed Meat Saw Inspections] = 0
        )
    )
)

If the above one can't help you get the expected result, please provide some raw data in the tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
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

3 REPLIES 3
guggu74
New Member

Try this:

tores with Zero Meat Saw Inspections =
IF (
    [Meat Saw Count] = 0,
    "N/A",
    CALCULATE (
        DISTINCTCOUNT ( 'Equip IDs'[Division-Store] ),
        FILTER ( 'Equip IDs', 'Equip IDs'[Equipment Product Type Descr] = "MEAT SAWS" )
            && FILTER ( 'Equip IDs', [Completed Meat Saw Inspections] = 0 )
    )
)

I get an error...

A_Scott_0-1696420789557.png

 

Hi @A_Scott ,

You can update the formula of measure [Stores with Zero Meat Saw Inspections] as below and check if it can return the expected result...

Stores with Zero Meat Saw Inspections =
IF (
    [Meat Saw Count] = 0,
    BLANK (),
    CALCULATE (
        DISTINCTCOUNT ( 'Equip IDs'[Division-Store] ),
        FILTER (
            'Equip IDs',
            'Equip IDs'[Equipment Product Type Descr] = "MEAT SAWS"
                && [Completed Meat Saw Inspections] = 0
        )
    )
)

If the above one can't help you get the expected result, please provide some raw data in the tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors