Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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)
]))
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
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
70 | |
63 | |
40 | |
28 | |
16 |