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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Distinct count based on column values

Need a measure to calculate Distinct count of IDs that have both Types - Type1 and Type2

 

Sample Data: 

 

ID

Column2

Column3

Type

1

Type1

2

Type1

2

Type1

2

Type2

1

Type1

3

Type2

2

Type2

1

Type1

4

Type2

4

Type1

4

Type2

 

ID 2 and 4 have both types. so expected result is 2.

3 REPLIES 3
KL718
Frequent Visitor

HI,

 

This is not the exact soultion but would help. It will give you output as below. Once you have it split the type & you can write DAx to calculate Distinct.

 

ID

Type
2Type1 Type1 Type2 Type2

 

 

https://www.youtube.com/watch?v=oseoa_2OYqg

@Anonymous 

 

As a MEASURE,,one way could be

 

Measure =
COUNTROWS (
    FILTER (
        VALUES ( Table1[ID] ),
        VAR temp =
            CALCULATETABLE ( VALUES ( Table1[Type] ) )
        RETURN
            CONTAINS ( temp, [Type], "Type1" )
            && CONTAINS ( temp, [Type], "Type2" )
    )
)

 

 


Regards
Zubair

Please try my custom visuals

@Anonymous

 

Another way could be

 

Measure 2 =
COUNTROWS (
    FILTER (
        VALUES ( Table1[ID] ),
        COUNTROWS (
            INTERSECT ( { "Type1", "Type2" }, CALCULATETABLE ( VALUES ( Table1[Type] ) ) )
        ) = 2
    )
)

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.