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
Anonymous
Not applicable

Looping through an API calling using another table

Hi!

 

For a dashboard im building I need to retrieve data using an API. However, within the URL of the API I need to specify an ID-like number to retrieve descriptive values. An example:

 

HTTPS://WWW.API_LINK.COM/category_line/(ID)/line

 

I have a table filled with Category_ID which I need to retrieve the data using the API above. So what i'm trying to do is:

 

HTTPS://WWW.API_LINK.COM/category_line/ LOOP(Category[ID]) /line.

 

However, the Powery Query Editor keeps telling me that I cannot combine functions like this together.  Thus, I was wondering if there is any other (perhaps better) way of doing this WITHOUT changing the nature of the API.

 

Thanks so much in advance!

2 REPLIES 2
mahoneypat
Employee
Employee

If your id is in a column called ID, you should be able to add a custom column with an expression like this.

 

= Web.Contents("HTTPS://WWW.API_LINK.COM/category_line/" & [ID] & "/line"

 

You many need to convert that column to text before this step, or use & Number.ToText([ID]) &

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi Pat!

First of all, thank you for taking the time to reply!

 

I used your solution, however, it gives me the following error:

 

Expression.Error: We cannot apply operator & to types Text and List.
Details:
Operator=&
Left=https://www.api-link.com/api/category/
Right=[List]

 

this is the line I have in set:

Json.Document(Web.Contents(#"API URL"&"/api/Category_line/"&Number.ToText(category[id])

Thank you in advance for replying!

 

Kind regards,

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.