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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
MatjoCol
Frequent Visitor

SQL Type UniqueIdentifier converted to text behaves differently in M vs DAX

I have two databases with a column Id in them. In one of the databases the Id column has type UniqueIdentifier. In the other database the type is varchar(50) as it contains ids in different formats. When you look at the Ids in SQL Management Studio they look like this: 

MatjoCol_0-1635845317720.png

When you import data into Power BI they look like this. 

MatjoCol_1-1635845545780.png

Power BI has converted the UniqueIdentifier to text and made it lower case as a GUID should be formatted according to RFC4122. If you merge the data in query mode it looks great. 

MatjoCol_2-1635845716195.png

However when you close and apply and look at the data it looks like this: 

MatjoCol_3-1635846200331.png

For some reason the Id column that was UniqueIdentifier originally is now represented with upper case and the merge fails as Source2 id is nvarchar that retains its capitalization. 

In order to get this merge to work you need to perform an additional step of lowercase in query editor. 

There seems to be some sort of glitch with how the data is represented and this could be quite difficult for a user to understand why it behaves like this. 

 

If you create a connection using model you can join these tables without any problem. 

 

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @MatjoCol 

 

I think what you are seeing is a result of the way DAX stores strings.  There's a good article about it here

 

Letter case-sensitivity in DAX, Power BI and Analysis Services - SQLBI

 

Basically DAX is case-insensitive and when it's storing strings, if it comes across anothjer string that is identical to one that it has already encountered, the second string is stored exactly the same as the first string.

 

So if it finds ABCD in your data first, then finds abcd, the 2nd string, abcd, actualy gets stored as ABCD.

 

So I suspect that DAX is finding your upper case ID first and storing all occurrences of it in upper case.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@PhilipTreacy 
Thank you for your reply! 
I read the article but I cannot see how it applies here. 
Create the following example: 
Query1 (connect to random database)

SELECT CAST('0011661B-2AFC-4308-9550-1BC80576EDA1' as UniqueIdentifier) as Id, '2021-11-01' as Date1

 

Query2 (connect to random database)

SELECT CAST('0011661b-2afc-4308-9550-1bc80576eda1' as varchar(50)) as Id2, '2021-11-01' as Date2

 

Import these, merge query1 with query2 on id = id2. This will look good in query editor. But you will get NULL on the join after you have applied it. 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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