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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
sdjelal
Regular Visitor

Query a API based on cell value and load response

I have an existing workbook which has both number/epoch dates and text. Based on the number in each row, I am looking to query an API that returns the subsequent columns. However, I want to return only the reward data based on each day (displayed as epoch time). Although, I consider myself an average excel user, I do not really know how to use power query. I'm using Excel 2021. Appreciate all help.

 01/03/2202/03/2203/03/22
67907   
69828   
294291   


For e.g., below is the API code for the first row item = 67907.

GET "https://api-apollo.pegaxy.io/v1/game-api/race/history/pega/67907"
Response{
"status": true,
"data": {
"Reward": "e.g. 26",
}
}

1 ACCEPTED SOLUTION

Hi @sdjelal 

 

Thank you for explaining. The Figure 3 is only for one ID, right? Based on Figure 3, you can first extract date from schedule column by converting it to date data type or adding a new column to get dates. 

vjingzhang_0-1649835440656.png

 

Then convert this query into a custom function with id as a parameter. Add "(id as number)=>" on the first row and replace the static id number with the parameter id. 

vjingzhang_1-1649836013505.png

 

Prepare another table which has all IDs in a column. Go to Add Column > Invoke Custom Function, under Function query box, select the function query created in previous step. And select id column to provide data for the id parameter. This will bring you a new table column. It will invoke the custom function for every row. After that, expand the table column to have reward and schedule values for all IDs. 

vjingzhang_3-1649836882666.png

 

Then you can apply the data, go to Power BI Desktop and use Matrix visual to display the result. Put ID on rows and date on columns. Put reward in Values well and select a proper aggregation type for it. 

 

Hope this is helpful. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @sdjelal 

 

What is epoch time? I called the API in Power Query and got a list of records. Every record has a reward value in it. Which one is the reward value to be extracted for this row 67907?

vjingzhang_0-1649389297570.png

 

Best Regards,
Community Support Team _ Jing

Hi, thanks for the reply. I was starting to get worried. I suppose, more explaining is required on my behalf, apologies for that. 

Once the initial API is called, converted to table and expanded, the only two data entries that are required are record and race (figure 1). Then, I expand race and only require schedule (figure 2), which then reveals the epoch times. I, then, converted the epoch times via power query to regular time and date format (figure 3). 

 

This is actually where I require the help. I would like to reach this data based on each ID within the table and then be able to organise/categorise the data (rewards) based on the dates.

 

Once again, apologies for not being clear.

 

1.PNG

Figure 1

 

2.PNG

Figure 2

3.PNG

 Figure  3

Hi @sdjelal 

 

Thank you for explaining. The Figure 3 is only for one ID, right? Based on Figure 3, you can first extract date from schedule column by converting it to date data type or adding a new column to get dates. 

vjingzhang_0-1649835440656.png

 

Then convert this query into a custom function with id as a parameter. Add "(id as number)=>" on the first row and replace the static id number with the parameter id. 

vjingzhang_1-1649836013505.png

 

Prepare another table which has all IDs in a column. Go to Add Column > Invoke Custom Function, under Function query box, select the function query created in previous step. And select id column to provide data for the id parameter. This will bring you a new table column. It will invoke the custom function for every row. After that, expand the table column to have reward and schedule values for all IDs. 

vjingzhang_3-1649836882666.png

 

Then you can apply the data, go to Power BI Desktop and use Matrix visual to display the result. Put ID on rows and date on columns. Put reward in Values well and select a proper aggregation type for it. 

 

Hope this is helpful. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors