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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SimonKragh
Frequent Visitor

Stuck with "nested" records

Hi,

 

I have been trying to develop an interactive dashboard to visualise performance for overwatch players, however i have gone stuck.

Firstly i created a hero dimension with the basical stats in form of playtime etc using the following api call:

 

Json.Document(Web.Contents("https://api.lootbox.eu/pc/eu/donatellow-2669/competitive-play/heroes"))

 

Afterwards i wanted to get performance by each individual hero by using the following API call (as illustrated in this article: http://datachix.com/2014/05/22/power-query-functions-some-scenarios/😞

 

Json.Document(Web.Contents("https://api.lootbox.eu/pc/eu/"& accountName &"/competitive-play/hero/"& charString & "/"))

 

Where accountName and charString is identifier for the account and which character. However, this returns the following result: 

recordsError.png

I have tried using the expand button which leads to the following result, which is not what i want:

expandError.png

Each record contains the following columns which i want to store directly in my table:

stats.png

Any suggestions to how i achieve this? 

1 ACCEPTED SOLUTION

@SimonKragh


 

The appove code gives me the record which contains a record. Do you have any suggestiosn how i can access the nested record directly from the above query?


Please try the formula below.

let getOWHeroesStats = (charString as text) =>
let Source = Json.Document(Web.Contents("https://api.lootbox.eu/pc/eu/donatellow-2669/competitive-play/hero/"& charString & "/")),
Hero = Record.FieldOrDefault(Source, charString),
#"Converted to Table" = Record.ToTable(Hero),
#"Transposed Table" = Table.Transpose(#"Converted to Table"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table")

in #"Promoted Headers"
in getOWHeroesStats

Following is the result for hero "Tracer".

Tracer.PNG

 

Regards

View solution in original post

6 REPLIES 6
ankitpatira
Community Champion
Community Champion

@SimonKragh I think it will work if you do it as two seperate data queries. So have another query with all your Json records. Then pivot it so columns (Roadhog, Lucio, Tracer) becomes rows in a new column (call it Character Name). Then Merge both queries using Character name column. Hope that make sense. 

@ankitpatira I tried your suggesting but it leads me to the same result within its own Query this time as seen below. 

query2.png

Which is quiet the same except i dont have the first columns with playtme etc.

 

Any other suggestions? 

 

Regards.

@SimonKragh Can you try Append instead of Merging. I think append will do the trick.

Hi.

 

Nope, didn't do the trick either 😕 

Isn't there someway in my functions that i can get the nested record directly to the column? 

let getOWHeroesStats = (charString as text) =>
  let Source = Json.Document(Web.Contents("https://api.lootbox.eu/pc/eu/donatellow-2669/competitive-play/hero/"& charString & "/"))
in Source
    in getOWHeroesStats

The appove code gives me the record which contains a record. Do you have any suggestiosn how i can access the nested record directly from the above query?

 

Best,

Simon

 

@SimonKragh


 

The appove code gives me the record which contains a record. Do you have any suggestiosn how i can access the nested record directly from the above query?


Please try the formula below.

let getOWHeroesStats = (charString as text) =>
let Source = Json.Document(Web.Contents("https://api.lootbox.eu/pc/eu/donatellow-2669/competitive-play/hero/"& charString & "/")),
Hero = Record.FieldOrDefault(Source, charString),
#"Converted to Table" = Record.ToTable(Hero),
#"Transposed Table" = Table.Transpose(#"Converted to Table"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table")

in #"Promoted Headers"
in getOWHeroesStats

Following is the result for hero "Tracer".

Tracer.PNG

 

Regards

@v-ljerr-msft Yes yes yes! Works like a charm! Thank you so much! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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