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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.