The URL of the API has the following format:
www.apiexample.com.br/SALES?dateStart=2022-01-01&dateEnd=today&lastCode=0The lastCode query parameter indicates where should the query start: with a limit of 200 records, the query get 200 records which ones have their saleCode greater than lastCode and are between dateStart and dateEnd. The lastCode by the way, shows the saleCode of the last sale inside the results fields.
To avoid doing the first load everytime I update the report, I was told to turn the incremental refresh on however, due to causes unknown to me it didn't work for my query (probably because it didn't manage to transform it into a native query). When I tried using incremental refresh, all the scheduled refreshes get timed out.
I was thinking if there's a way to build a query where I get a "automated incremental refresh" i.e., inside the power query code, I get the last code from my table to update only records with saleCode greater than it, avoiding get to load all the data everytime
The loop that I'm currently using to build the list of queries is shown below:
let
Fonte = List.Generate(
()=> [Result = FUNCAO_MOVIMENTO(0,"SALE?")],
each [Result]<>null,
each [Result = try FUNCAO_MOVIMENTO([Result][lastCode],"SALE?") otherwise null]
)
The FUNCAO_MOVIMENTO is as shown:
(lastCode, Consulta as text)=>
let
Fonte= Json.Document(Web.Contents("
www.apiexample.com.br/",
[RelativePath = Consulta,
Query = [
dataStart = Date.ToText(DI,[Format="yyyy-MM-dd"]),
dataEnd = Date.ToText(DateTime.Date(DateTime.LocalNow()),[Format="yyyy-MM-dd"]),
lastCode= Number.ToText(lastCode) ]]))
in
Fonte