cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills 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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors