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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
manideep547
Helper III
Helper III

Different Customers

Hi all,

I have 4 different tables having the same customers and Id for the  all the 4 tables I need a count of the Ids who belong only to one table 
Example ID 1 having Transaction only on table A but not in Table B, Table C, Table D
Table A                                     Table B                               Table C                            Table D
ID                                                ID                                  ID                                             ID      
111                                            111                                 222                                           333
222                                           333                                  444                                            555
Count=2
111,222,333 Id has a transaction in two tables so we can ignore 
444,555 Id having Transaction only in one table then we have to count those IDS 

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @manideep547 ,

 

SingleIDs = 
VAR _unionOfAllTables = UNION(TableA, TableB, TableC, TableD)
VAR _unionWithOccurenceColumn = ADDCOLUMNS(_unionOfAllTables, 
                                "occurences", 
                                VAR _curID = [ID]
                                RETURN
                                COUNTROWS(FILTER(_unionOfAllTables, [ID] = _curID)))
RETURN
COUNTROWS(FILTER(_unionWithOccurenceColumn, [occurences] = 1))

This measure works, see attached PBIX. (please ignore Table1 and Table2, those were for other question).

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

I think that what @amitchandak suggested will work although I did not try its implementation. I went about this a little differently which I believe is more computationally efficient as it avoids measures and table scans, etc. Basically, you need a customer dimension table. Assuming that your actual data is more complex than presented, I did that this way:

 

 

Table = 
    DISTINCT(
        UNION(
            SELECTCOLUMNS('TableA',"ID",'TableA'[ID]),
            SELECTCOLUMNS('TableB',"ID",'TableB'[ID]),
            SELECTCOLUMNS('TableC',"ID",'TableC'[ID]),
            SELECTCOLUMNS('TableD',"ID",'TableD'[ID])
        )
    )

 

 

Now, create relationships based on ID between this table and your other tables. Then just create this column in Table:

 

 

Column = 
    VAR __1 = IF('Table'[ID] IN RELATEDTABLE(TableA),1,0)
    VAR __2 = IF('Table'[ID] IN RELATEDTABLE(TableB),1,0)
    VAR __3 = IF('Table'[ID] IN RELATEDTABLE(TableC),1,0)
    VAR __4 = IF('Table'[ID] IN RELATEDTABLE(TableD),1,0)
RETURN
    IF(__1 + __2 + __3 + __4 = 1,1,0)

 

 

All you need to do now is use Column in any visual with an aggregation of Sum. This method will be far more efficient given large dataset sizes. PBIX is attached.

 

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @manideep547 ,

 

SingleIDs = 
VAR _unionOfAllTables = UNION(TableA, TableB, TableC, TableD)
VAR _unionWithOccurenceColumn = ADDCOLUMNS(_unionOfAllTables, 
                                "occurences", 
                                VAR _curID = [ID]
                                RETURN
                                COUNTROWS(FILTER(_unionOfAllTables, [ID] = _curID)))
RETURN
COUNTROWS(FILTER(_unionWithOccurenceColumn, [occurences] = 1))

This measure works, see attached PBIX. (please ignore Table1 and Table2, those were for other question).

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

Create a common customer dimension

customer =distinct(union(all(tableA[ID]),all(tableB[ID]),all(tableC[ID]),all(tableD[ID])))

Create a combined measure

measure = count(tableA[ID]) + count (tableB[ID]) + count (tableC[ID]) + count (tableD[ID])

Create 1 transaction measure

Gt 1 = sumx(filter(summarize(customer, customer[ID],"_sum",[measure]),[_sum]<=1),[_sum])
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.