cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Egor_Paulig_RUS
Frequent Visitor

DAX count unique values after union

Hi everybody,

I am trying to create measure counting unique values of particular column, which is the result of UNION of two columns with similar data from two diffrent tables. It looks much easier with example 🙂  

post.PNG

It is not my buisness caase, but similar to it.  My tables have different structure, so I can perform UNION only over columns. And the issues is that DISTINCOUNT works only with column, and in my case I can specify particular column name after UNION statement.

Please help me with this case.

Thank you in advance!

3 REPLIES 3
Community Support
Community Support

Re: DAX count unique values after union

Hi @Egor_Paulig_RUS ,

 

You can create new measure.

 

Measure = var t=DISTINCT(UNION(SELECTCOLUMNS(Table1,"column1",Table1[sales_manager]),SELECTCOLUMNS(Table2,"column1",Table2[manager])))

return COUNTX(t,[column1])

 

6.png 

 

 

 

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Egor_Paulig_RUS
Frequent Visitor

Re: DAX count unique values after union

Hi @v-xicai ,

Thank you for the reply! 

Unfortunately DISTINCT doesn't want to accept table expression after UNION statement...

AkhilAshok Solution Sage
Solution Sage

Re: DAX count unique values after union

Maybe something like this:

Manager # =
VAR ManagerTable1 =
    DISTINCT ( Table1[sales_manager] )
VAR ManagerTable2 =
    DISTINCT ( Table2[manager] )
VAR CombinedManagers =
    UNION ( ManagerTable1, ManagerTable2 )
VAR UniqueManagers =
    DISTINCT ( CombinedManagers )
RETURN
    COUNTROWS ( UniqueManagers )

Helpful resources

Announcements
Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors