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
mluleci
New Member

Errors in Merged Table: Detected Type Mismatches

Hello Power BI forums,

I have a report where I pull JSON data from two URLs, and then process them as follows:

1. Convert both JSON dictionaries to tables

2. Merge them based on text columns

3. Do lots of processing on the merged table

Everything works fine on my machine, but when the report is refreshed on my collegue's machine and the processing is re-done, there is an error "Detected Type Mismatches". This appears as a brand new table (under Errors) where Power BI has seemingly decided to do unnecessary extra processing on the merged table. The advanced editor reveals this code:

 

 

let
Source = #"Merged Table",
   #"Detected Type Mismatches" = let
      tableWithOnlyPrimitiveTypes = Table.SelectColumns(Source, Table.ColumnsOfType(Source, {type nullable number, type nullable text, type nullable logical, ...})),
      recordTypeFields = Type.RecordFields(Type.TableRow(Value.Type(tableWithOnlyPrimitiveTypes))),
      fieldNames = Record.FieldNames(recordTypeFields),
      fieldTypes = List.Transform(Record.ToList(recordTypeFields), each [Type]),
      pairs = List.Transform(List.Poisitions(fieldNames, (i) => (fieldNames{i}, (v) => if v = null or Value.Is(v, fieldTypes{i}) then v else error [Message = "The type of value does not match the type of the column.", Detail = v], fieldTypes{i}))
in
...

 

 

I've copied this by hand, so excuse any typos. Why are type checks being done after the merge and all other processing is completed?

M.

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @mluleci,

Can you please share some result JSON data from the URL? They should help us clarify the data structure and testing to troubleshoot with your code.

How to Get Your Question Answered Quickly  

BTW. does this device test with URLs with different credentials? If that is the case, power bi will cache used credentials at the local device. Please clean up these cached data and credentials at first to exclude the issues caused by cached data conflict.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Mr. Sheng,

 

The API access uses a token and a key, which are included in the request headers, so the cache should not be affecting the results. I cleared the caches and tried again anyways, and it still works on my machine but not on my collegues. I have attached some JSON data samples for one row of the merged table, from each URL.

 

The tables are related as shown below:

relationships.png

Processing on the configuration data:

 

 

let
    Source = Json.Document(Web.Contents("https://apis.registrar.com/api/v2/domains/configuration", [Headers=[Accept="application/json", Authorization="Bearer XXXX-XXXX-XXXX-XXXX", apikey="XXXXXXXXXXXXXXX"]])),
    #"Converted to Table" = Record.ToTable(Source),
    #"Kept Range of Rows" = Table.Range(#"Converted to Table",1,1),
    #"Removed Columns" = Table.RemoveColumns(#"Kept Range of Rows",{"Name"}),
    #"Expanded Value" = Table.ExpandListColumn(#"Removed Columns", "Value"),
    #"Expanded Value1" = Table.ExpandRecordColumn(#"Expanded Value", "Value", {"domain", "domainLabel", ...}, {...})
in
    #"Expanded Value1"

 

 

Processing on the domains data:

 

 

let
    Source = Json.Document(Web.Contents("https://apis.registrar.com/api/v2/domains", [Headers=[Accept="application/json", Authorization="Bearer XXXX-XXXX-XXXX-XXXX", apikey="XXXXXXXXXXXXXXXXXXXXXX"]])),
    #"Converted to Table" = Record.ToTable(Source),
    #"Kept Range of Rows" = Table.Range(#"Converted to Table",1,1),
    #"Removed Columns" = Table.RemoveColumns(#"Kept Range of Rows",{"Name"}),
    #"Expanded Value" = Table.ExpandListColumn(#"Removed Columns", "Value"),
    #"Expanded Value1" = Table.ExpandRecordColumn(#"Expanded Value", "Value", {"qualifiedDomainName", "domain", ...}, {...})
in
    #"Expanded Value1"

 

 

Processing done on the merged table: [link]

 

As you can see, the merge is done based on the "qualifiedDomainName" and "domain" fields from the domains and configuration tables respectively.

 

Data samples:

[configuration] and [domains]

HI @mluleci,

Have you tried to use your formula on another device? (exclude the current two devices)

If these formulas only failed on your colleague's device, they may be a specific device issue. You can check the corresponding policy and firewall settings if they block the M query request. (you can use fiddler to trace power bi desktop client requests)

Fiddler Classic | Original Web Capturing Tool for Windows (telerik.com)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.