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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Gekko1
Helper I
Helper I

Use query fields as parameters

So, I am currently having this issue with the API where I get my data from: due to massive amounts of data for the timespan I'm looking for, I'm getting timeout issues when scheduling refreshes for the reports on power service.

Considering that the records I get from the API are formatted as shown, below:

{
    "lastCode": 164504092,
    "results": [
        {
            "companyCode": 6657,
            "saleCode": 164504092,
            "employeeCode": 55367,
            "customerCode": 456456,
            "dateTime": "2023-02-20T10:50:00.000-03:00",
            "saleTotal": 371.47,
        }
    ]
}

The URL of the API has the following format:
www.apiexample.com.br/SALES?dateStart=2022-01-01&dateEnd=today&lastCode=0
The 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


0 REPLIES 0

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors