cancel
Showing results for 
Search instead for 
Did you mean: 
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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors