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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
AnkitaChatterje
Frequent Visitor

How to create a conditional column from APIs using the values of a given column?

Hi,

 

I have a table of IDs which I need to fetch data from a particular API. This API needs "ID" as an input and it keeps changing for every ID.

 

I want to store the values of a particular key so obtained from each API in the form of an additional column in the same table. So, I'll have two columns in the table - 1) ID ;

                                                              2) key value (obtained from each API)

 

Here's what I have done so far -

pic of machine ID table in Power BI query.PNGpic of machine ID link in Power BI query.PNG

 

Kindly suggest me how to write this query.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @AnkitaChatterje,

 

My formula is custom function, please add blank query and open advanced editor to use my formula to replace.

After this steps, you can add new column on tables which contains id list, then use id column as parameter to invoke functions.

 

Sample steps:

34.gif

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @AnkitaChatterje,

 

You can write a custom function to your queries, then add custom column on table who have 'user id' column and use this id as parameter to invoke custom function.

 

Sample funciton:

let
    LoadData=(userKey as text) as table=> 
    let 
        Source= Record.ToTable(Json.Document(Web.Contents("Https://api.machinesense.com/api/mechine/"&userKey)))
    in	
	Source
    in
LoadData

Regards,

Xiaoxin Sheng

Hi,

 

Thanks for the suggestion. But can you kindly explain the steps that I need to incur while creating the custom column. I have tried creating a custom column using this approach, but I am getting an error.

 

QueryQueryHere, I am entering a column name as "parameter". Example: #"TableName"[machine_id]Here, I am entering a column name as "parameter". Example: #"TableName"[machine_id]pic of sample error in Power Bi query.PNG

Anonymous
Not applicable

HI @AnkitaChatterje,

 

My formula is custom function, please add blank query and open advanced editor to use my formula to replace.

After this steps, you can add new column on tables which contains id list, then use id column as parameter to invoke functions.

 

Sample steps:

34.gif

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.