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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ayushbot
New Member

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
Super User
Super User

@ayushbot 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@ayushbot 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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, @ayushbot 

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.