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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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