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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Null/Blank value when making a distinct union between tables

Hi, 

 

I'm trying to create a relationship between elements in different tables with the distinct union DAX, but it's returning a null/blank result in the new table, which then won't let me create relationships. 

 

I've used this before and it's worked fine.. 

 

Can anyone help with this?

 

Thank you!

 

 

 

 Capture15.PNG

1 ACCEPTED SOLUTION
AlbertoFerrari
Most Valuable Professional
Most Valuable Professional

First, use DISTINCT instead of VALUES, so to avoid the blank row which might be created due to invalid relationships. Then, if BLANK is present somwhere among teh values, you can simply surround the whole code with a FILTER that removes the blank:

 

FILTER ( 
    DISTINCT ( 
        UNION ( 
             DISTINCT ( T1[C] ),
             DISTINCT ( T2[C] )
        )
     ),
     NOT ISBLANK ( [C] )
)


Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI

View solution in original post

2 REPLIES 2
AlbertoFerrari
Most Valuable Professional
Most Valuable Professional

First, use DISTINCT instead of VALUES, so to avoid the blank row which might be created due to invalid relationships. Then, if BLANK is present somwhere among teh values, you can simply surround the whole code with a FILTER that removes the blank:

 

FILTER ( 
    DISTINCT ( 
        UNION ( 
             DISTINCT ( T1[C] ),
             DISTINCT ( T2[C] )
        )
     ),
     NOT ISBLANK ( [C] )
)


Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI

When using NOT ISBLANK for only one column wrapped inside the DISTINCT() it's clear. But when aggregating 2 columns wrapped in a UNION() I didn't understand why the engine just gives me the first table[column] as a option to wrap inside the filter function. 

 

For example, when I use the NOT ISBLANK("I only can add the T1[C] option)

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.