Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi All.
In the other opportunity, @ThxAlot helped me with a solution. Now, I need to complement the other solution.
The other problem was solved with the following code:
let
Source = List.Accumulate(
{1..100},
{},
(s,c) => s & Json.Document(Web.Contents("http://api.worldbank.org/v2/country?format=json&page=" & Number.ToText(c))){1}
),
#"Table From Records" = Table.FromRecords(Source)
in
#"Table From Records"
Now I need to bring all "GDP (current US$)" indicator of all countries. Using the past solution I have:
let
Source = List.Accumulate(
{1..10},
{},
(s,c) => s & Json.Document(Web.Contents("https://api.worldbank.org/v2/country/USA/indicator/NY.GDP.MKTP.CD/?format=json&page=" & Number.ToText(c))){1}
),
#"Table From Records" = Table.FromRecords(Source)
in
#"Table From Records"
Here's the problem. I need change "USA" for a list of countries.
Ty folks
Solved! Go to Solution.
Hi @WillY_OneEyed ,
To modify the code to include a list of countries instead of just "USA", you can replace the hardcoded "USA" with a parameter that takes a list of countries. Here's an updated version of the code:
let
GetGDP = (country as text) =>
let
Source = List.Accumulate(
{1..10},
{},
(s,c) => s & Json.Document(Web.Contents("https://api.worldbank.org/v2/country/" & country & "/indicator/NY.GDP.MKTP.CD/?format=json&page=" & Number.ToText(c))){1}
),
#"Table From Records for & country" = Table.FromRecords(Source)
in
#"Table From Records for & country",
Countries = {"USA", "CAN", "MEX"}, // Replace with your list of countries
GDPTables = List.Transform(Countries, each GetGDP(_)),
CombinedTable = Table.Combine(GDPTables)
in
CombinedTable
This code defines a function called "GetGDP" that takes a country as a parameter and returns a table of GDP data for that country. It then applies this function to each country in the list using the List.Transform function, and combines the resulting tables into a single table using Table.Combine.
Best regards,
Community Support Team_yanjiang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @WillY_OneEyed ,
To modify the code to include a list of countries instead of just "USA", you can replace the hardcoded "USA" with a parameter that takes a list of countries. Here's an updated version of the code:
let
GetGDP = (country as text) =>
let
Source = List.Accumulate(
{1..10},
{},
(s,c) => s & Json.Document(Web.Contents("https://api.worldbank.org/v2/country/" & country & "/indicator/NY.GDP.MKTP.CD/?format=json&page=" & Number.ToText(c))){1}
),
#"Table From Records for & country" = Table.FromRecords(Source)
in
#"Table From Records for & country",
Countries = {"USA", "CAN", "MEX"}, // Replace with your list of countries
GDPTables = List.Transform(Countries, each GetGDP(_)),
CombinedTable = Table.Combine(GDPTables)
in
CombinedTable
This code defines a function called "GetGDP" that takes a country as a parameter and returns a table of GDP data for that country. It then applies this function to each country in the list using the List.Transform function, and combines the resulting tables into a single table using Table.Combine.
Best regards,
Community Support Team_yanjiang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!