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
bbwong
Helper I
Helper I

Unique Combinations

Trying to find best way to identify combinations and to count distinct IDs.

For example:

 

Capture 1.PNG

Would like output as this:

Capture 2.PNG

With thanks,

BB

1 ACCEPTED SOLUTION

Hey @bbwong ,

 

you're absolutely right.

In this case change the COUNTROWS to a DISTINCTCOUNT of the ID:

Red & Blue = 
CALCULATE(
    DISTINCTCOUNT( myTable[ID] ),
    myTable[Category] = "RED" || myTable[Category] = "BLUE"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

3 REPLIES 3
selimovd
Super User
Super User

Hey @bbwong ,

 

you can do that with DAX measures. An approach like this should work:

Red & Blue = 
CALCULATE(
    COUNTROWS( myTable ),
    myTable[Category] = "RED" || myTable[Category] = "BLUE"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi @selimovd ,

 

Thank you for your prompt reply.

For the Red and Blue combination, your DAX measure is returning a value of 8 (counting each row containing red or green in the Category column, rather than giving me distinct count of ID = 2.

 

For example:

ID123 effectively has a combination of RED, RED, BLUE and ID 1011 has a combination of RED, BLUE, BLUE. I would like to ignore duplicate categories and define this as a RED & BLUE combination.

 

Hope I'm making sense.

 

Cheers,

Bee Bee

Hey @bbwong ,

 

you're absolutely right.

In this case change the COUNTROWS to a DISTINCTCOUNT of the ID:

Red & Blue = 
CALCULATE(
    DISTINCTCOUNT( myTable[ID] ),
    myTable[Category] = "RED" || myTable[Category] = "BLUE"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.