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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Alienvolm
Helper IV
Helper IV

Distinct count across two columns

Hi, 

 

I'm trying to create a measure that calculates the distinct count of active users across two columns, as in the example below:

 

Alienvolm_0-1632420460107.png

 

In both columns there are 4 active users, but my result would not be the sum of the two distinct counts (8): the result would be 6 (as there are only 6 email addresses in total - sometimes they're senders and sometimes they're receivers). 

 

My process would be to append the two columns and then calculate a distinct count of the resulting column, but I have to use a measure as I'm connected in DirectQuery mode

 

Any suggestions on how I can accomplish this? 

 

Thanks! 

 

Alienvolm

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Alienvolm Essentially MC Aggregations: Multi-Column Aggregations (MC Aggregations) - Microsoft Power BI Community

 

In your case:

Measure =
  COUNTROWS(
    DISTINCT(
      UNION(
        SELECTCOLUMNS('Table',"Email",[Sender]),
        SELECTCOLUMNS('Table',"Email",[Receiver])
      )
    )
  )


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Alienvolm Essentially MC Aggregations: Multi-Column Aggregations (MC Aggregations) - Microsoft Power BI Community

 

In your case:

Measure =
  COUNTROWS(
    DISTINCT(
      UNION(
        SELECTCOLUMNS('Table',"Email",[Sender]),
        SELECTCOLUMNS('Table',"Email",[Receiver])
      )
    )
  )


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks a lot! That worked!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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