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
Anonymous
Not applicable

Combining Data from two different columns stored in a variable

Consider the following two variables:

VAR A = MembershipHistory[Membership]

VAR B = Memberships[Membership]

Table MembershipHistory and Memberships have some common values in their column Membership and I want their distinct count. How can I join data from both variables so that I could apply distinct count on it. Please help.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try:

RETURN
  COUNTROWS(DISTINCT(UNION(A, B)))


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...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try:

RETURN
  COUNTROWS(DISTINCT(UNION(A, B)))


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...
Anonymous
Not applicable

Hi Greg, that works for this problem, but I also have another measure where the variable A is storing 3 columns and variable B is storing 2 columns. The union will not work there as the no of columns are not same. Can you please help with that too?

 

Thanks in advance

Hi, @Anonymous 

Please check if formula below could help:

COUNTROWS (
    DISTINCT ( UNION ( VALUES ( A[Column1] ), VALUES ( B[Column1] ) ) )
)

Best Regards,
Community Support Team _ Eason

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.