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
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

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.