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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

DISTINCTCOUNT of Rows filtered by other column

Trying to create a measure to use in a card.

 

FieldTime
10
12
12
11
20
2-1
30
30
30

 

 Distinctcount of row (Field) has to be filtered and not counted if it contains a time value of <0.

Trying to get an outcome like this.

 

Sum of Distinct field with out negative t

ime time value

2

 

Still new to PowerBI an DAX. Any help is appreciated! 🙂

1 ACCEPTED SOLUTION
ERD
Community Champion
Community Champion

@Anonymous , you can try this measure:

dcount =
VAR t =
    FILTER (
        ADDCOLUMNS (
            VALUES ( 'Table'[Field] ),
            "minv",
                VAR current_field = CALCULATE ( SELECTEDVALUE ( 'Table'[Field] ) )
                RETURN
                    CALCULATE ( MIN ( 'Table'[Time] ), 'Table'[Field] = current_field )
        ),
        [minv] >= 0
    )
RETURN
    COUNTROWS ( t )

ERD_0-1694761044619.png

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

Stand with Ukraine!


Here is an official way you can support Ukraine financially:
Come Back Alive foundation: https://savelife.in.ua/en/

Thank you!

View solution in original post

5 REPLIES 5
123abc
Community Champion
Community Champion

To calculate the distinct count of rows in the "Field" column, excluding those with a "Time" value less than 0, you can create a DAX measure. Here's how you can do it:

 

DistinctCountFiltered = VAR FilteredTable = FILTER('YourTableName', 'YourTableName'[Time] >= 0) RETURN DISTINCTCOUNTX(FilteredTable, 'YourTableName'[Field])

 

Replace 'YourTableName' with the actual name of your table.

This measure first filters the table to exclude rows where the "Time" column has a value less than 0. Then, it calculates the distinct count of the "Field" column based on the filtered table.

Once you create this measure, you can use it in a card visual to display the sum of distinct "Field" values without negative "Time" values.

ERD
Community Champion
Community Champion

@Anonymous , you can try this measure:

dcount =
VAR t =
    FILTER (
        ADDCOLUMNS (
            VALUES ( 'Table'[Field] ),
            "minv",
                VAR current_field = CALCULATE ( SELECTEDVALUE ( 'Table'[Field] ) )
                RETURN
                    CALCULATE ( MIN ( 'Table'[Time] ), 'Table'[Field] = current_field )
        ),
        [minv] >= 0
    )
RETURN
    COUNTROWS ( t )

ERD_0-1694761044619.png

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

Stand with Ukraine!


Here is an official way you can support Ukraine financially:
Come Back Alive foundation: https://savelife.in.ua/en/

Thank you!

Anonymous
Not applicable

Hello @ERD ERD,

 

This solution does work for what I originally asked, but for my real purpose I need it to fit into a percentage calculation. I see I needed to be more specific, I apologize.

 

Adjusted % on Time = SUMX(VALUES('Master INV'[Field]),CALCULATE(MAX('Master INV'[Ratio for on time completion calculation]),'Master INV'[Alloted_Prep_Time]>-1)/(FILTER (
        ADDCOLUMNS (
            VALUES ( 'Master INV'[Field] ),
            "minv",
                VAR current_field = CALCULATE ( SELECTEDVALUE ( 'Master INV'[Field] ) )
                RETURN
                    CALCULATE ( MIN ( 'Master INV'[Alloted_Prep_Time] ), 'Master INV'[Field] = current_field )
        ),
        [minv] >= 0
    )
    RETURN
        COUNTROWS(t)
    *100))
 
The RETURN command does not play nicely. I hope this gives better idea to what I am trying to do. Thank you for your resolution, you infact did answer my original question, I failed to ask exactly what I needed.
ERD
Community Champion
Community Champion

I don't know what you're trying to calculate. Your example contains more columns. You need to provide a correct demo with the expected result.

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

Stand with Ukraine!


Here is an official way you can support Ukraine financially:
Come Back Alive foundation: https://savelife.in.ua/en/

Thank you!

DataNinja777
Super User
Super User

Hi @Anonymous ,

 

I've prepared your required output, but the answer is not 2 but is 3 as shown below:

Sakiko_0-1694746540603.png

I attach the link to the pbix file below:

DISTINCTCOUNT of Rows filtered by other column.pbix

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.