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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
TBSST
Frequent Visitor

Calculating distinct count of ID's while meeting either or condition

Hi all, 

 

I am trying to get a distinct total for a card visualtions of ID's that have met either or one of the conditions. My issue is arrising as the conditions sit across different tables and i am unsure how to combine them together without double counting the ID's. 

 

Example: 

Table 1 Table 2  Table 3 
ID IDType1 IDType2
1 11 1a
2 12 2a
3 21 2a
4 31 3b
5 42 4b
6 51 4a
7 51 5b
8 62 6a
  71 6b
  81 7a
     7a
     7b
     8a
     8b
     8b

 

I am wanting to count the distint number of ID's that have had at least one Type 1 '1', and/or at least one Type2 'a'. The ID can have both Types, or just one Type to be counted, although the ID should not be counted twice if they have both. 

 

Any help would be appreciated. 

 

Thank you. 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @TBSST 

Please try

ID Count =
COUNTROWS (
    DISTINCT (
        UNION (
            CALCULATETABLE ( VALUES ( Table2[ID] ), Table2[Type1] = "1" ),
            CALCULATETABLE ( VALUES ( Table3[ID] ), Table3[Type2] = "a" )
        )
    )
)

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @TBSST 

Please try

ID Count =
COUNTROWS (
    DISTINCT (
        UNION (
            CALCULATETABLE ( VALUES ( Table2[ID] ), Table2[Type1] = "1" ),
            CALCULATETABLE ( VALUES ( Table3[ID] ), Table3[Type2] = "a" )
        )
    )
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.