Search code examples
powerbidaxmultiple-columnsdistinct

How do I create a distinct count column of two associated columns in one measure


I have a dataset that looks like this

ID 1   ID 2
123456 234567
123456 234567
234567 123456
345678 123456
345678 234567
345678 456789
123456 345678
234567 123456

I create a measure that if added to a visual table would look like this

ID 1   Count of unique ID 2
123456 2
234567 1
345678 3

Notice "123456" is associated with only "234567" and "345678". "234567" is only associated with "123456" hence "unique" counts.

I created a measure that looks like this.

Unique ID involved = DISTINCTCOUNT(TABLE[ID 2])

However this only works when I associate the measure with the first column(ID 1) like in a table but not in the actual measure. When I run it alone it counts the unique values in column 2(ID2) and its not exactly what I want. I want to do in one measure or table the "count of ID2 associated relative to ID1". Is this possible?

Also note since the visual sets the desired output, is there a way to just pull the result of the visual as a table or create a measure off the visual result that adjusts dynamically through filters as well if easier?


Solution

  • Can you try this

    Measure = COUNTX(SUMMARIZE('fact','fact'[ID1],'fact'[ID 2]),'fact'[ID 2])