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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply

Refresh and append query from API

Hello, I need help, because I want to fetch data from an API but I need this data to be updated daily and to be incremental. I don't know if using the "Incremental Refresh" functionality would work, because as an API parameter I need to pass the desired date, in this case I always want to search for a single day and always being the day before the current day.
I have two identical queries, one of them has a static date, the desired date is written in text, while the other query is using a formula to obtain yesterday's date. I need the query with yesterday's date to be executed every day, incrementing the other query.
Example: assuming that the static date is 2023-01-01, on the 3rd the dynamic query will look for data from 2023-01-02 and make the combination. On the 4th it will look for data from 2023-01-03 and combine it with the other results, resulting in a table with data from the 1st, 2nd and 3rd and so on.

 

The static:

body = "{
""call"":""method"",
""app_key"":""XXX"",
""app_secret"":""YYY"",
""param"":[
{
""page"": 1,
""records"": 500,
""date_start"": ""26/11/2023"",
""date_end"": ""26/11/2023""
}
]
}",
Data=Json.Document(Web.Contents(
"https://api", [
Headers=[#"Content-Type"="application/json"],
Content=Text.ToBinary(body)
]))

 

 

The dynamic:

body = "{
""call"":""method"",
""app_key"":""XXX"",
""app_secret"":""YYY"",
""param"":[
{
""page"": 1,
""records"": 500,
""date_start"": """ & DateTime.ToText(Date.AddDays(DateTime.LocalNow(),-1), [Format="dd/MM/yyyy"]) & """,
""date_end"": """ & DateTime.ToText(Date.AddDays(DateTime.LocalNow(),-1), [Format="dd/MM/yyyy"]) & """
}
]
}",
Data=Json.Document(Web.Contents(
"https://api/", [
Headers=[#"Content-Type"="application/json"],
Content=Text.ToBinary(body)
]))

1 REPLY 1
ppm1
Solution Sage
Solution Sage

You can use incremental refresh for this. Just create your RangeStart and RangeEnd parameters and use RangeStart in place of DateTime.LocalNow(). Or you could start with a single column table with your desired dates and add a custom column with the API call on each row.

 

Pat

Microsoft Employee

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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