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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors