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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors