Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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.
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
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:
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
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
94 | |
89 | |
32 | |
28 |