Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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:
When you import data into Power BI they look like this.
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.
However when you close and apply and look at the data it looks like this:
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.
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
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.
User | Count |
---|---|
128 | |
108 | |
100 | |
65 | |
62 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |