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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
pandeyml
Frequent Visitor

Calculate unique values according to categories

Hello guys,

I need some ideas/help with a unique value prob.

I have a table like below. I have two categories, ID coluumn plus a Date column.  Each ID is supposed to have one [Category 1] and one [Category 2] but some of the ID's appear twice or thrice in the data. How can I calculate number of values which appear more than once.  I cannot get an idea how to show a summary of the data according to category 1 and category 2. Any help is appreciated. 

IDDATECategory 1Category 2
121202/11/22ABS0
121202/11/22IGN1
145602/11/22ABS0
123302/11/22XLT2
145602/11/22IGN1
121202/11/22ABS1
123302/11/22XLT0
458602/11/22ABS0
458602/11/22IGN1
121202/11/22IGN2
458602/11/22XLT2
123302/11/22XLT0
121202/11/22ABS1
121202/11/22IGN2
1 ACCEPTED SOLUTION
v-jialluo-msft
Community Support
Community Support

Hi @pandeyml ,

 

Please follow these steps:

(1) Create a new measure

COUNTROW = 
COUNTROWS (
    FILTER (
        ALL ( 'Table' ),
        'Table'[ID] = MAX ( 'Table'[ID] )
            && 'Table'[Category 1] = MAX ( 'Table'[Category 1] )
            && 'Table'[Category 2] = MAX ( 'Table'[Category 2] )
    )
)

 

 

(2)Final output

vjialluomsft_0-1669009592941.png

 

 

Best Regards,

Gallen Luo

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

2 REPLIES 2
v-jialluo-msft
Community Support
Community Support

Hi @pandeyml ,

 

Please follow these steps:

(1) Create a new measure

COUNTROW = 
COUNTROWS (
    FILTER (
        ALL ( 'Table' ),
        'Table'[ID] = MAX ( 'Table'[ID] )
            && 'Table'[Category 1] = MAX ( 'Table'[Category 1] )
            && 'Table'[Category 2] = MAX ( 'Table'[Category 2] )
    )
)

 

 

(2)Final output

vjialluomsft_0-1669009592941.png

 

 

Best Regards,

Gallen Luo

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

daXtreme
Solution Sage
Solution Sage

 

[# IDs > 1] = // measure
// This measure returns the number of distinct
// ID's that are visible in the current context
// and which are duplicated in the whole set.
var AllDoubledIds =
    CALCULATETABLE(
        FILTER(
            DISTINCT( T[ID] ),
            // Will select only those ID's that
            // have at least 2 rows in the whole
            // table.
            CALCULATE( COUNTROWS( T ) > 1 )
        ),
        // Remove all the filters from the table.
        REMOVEFILTERS( )
    )
var CountOfsDoubledIds = 
    COUNTROWS(
        // Will return those ID's visible
        // in the current context that are
        // duplicated in the whole dat set.
        INTERSECT(
            DISTINCT( T[ID] ),
            AllDoubledIds
        )
    )
RETURN
    CountOfDoubledIds

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.