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
Bessonnizza
Helper II
Helper II

Iterate function without cache result

Hello all!

 

I have a request to a webservice that returns an authorization token: fnAuthorization. I use List.Generate function to iterate function to get different tokens, but when I call fnAuthorization or update data, Fiddler show that power bi makes only one request to the service and return one token in all rows.

 

Does anyone know how to force power bi to make several requests of the same type instead of one? I will be glad for any help.

 

Screenshot_1.png

Result

 

 

 

let
    result = List.Generate(
        () => [i=0, res=fnAuthorization()],
        each [i]<10,
        each [i=[i]+1, res=fnAuthorization()],
        each [res]

    ),
    #"Converted to Table" = Table.FromList(result, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandTableColumn(#"Converted to Table", "Column1", {"SessionId"}, {"SessionId"})
in
    #"Expanded Column1"

 

 

 

 fnAuthorization

 

 

 

let
    Source = () => let
            data = Json.FromValue([Login="",Password=""]),
            headers = [#"accept"="application/json; charset=utf-8", #"Content-Type"="application/json"],
            web = Web.Contents("url", [ Content = data, Headers = headers, ManualStatusHandling = {404, 400}]),
            result = Json.Document(web),
            #"Converted to Table" = Record.ToTable(result),
            #"Pivoted Column" = Table.Pivot(#"Converted to Table", List.Distinct(#"Converted to Table"[Name]), "Name", "Value")
        in
            #"Pivoted Column"
in
    Source

 

 

 

 

2 REPLIES 2
Anonymous
Not applicable

I don't know at all the subject and the environment of API calls and WEB accesses, but I am interested in following the discussion.
In the meantime, I would be curious to know the result of a test that I cannot do.
you could adapt this code to your case with your function instead of f (x) and see if this "bypasses" the effect of caching

 

 

 

 

 

let  
  lf=List.Repeat({f},10),
    result = List.Generate(
        ()=> [i=0, res=lf{i}(i)],
        each [i]<10,
        each [i=[i]+1, res=lf{[i]}(i)],
        each [res]

    ),
f=(x)=>x+1

    in
    result

 

 

 

let  
  lf=List.Repeat({f},10),
    result = List.Generate(
        ()=> [i=0, res=lf{i}()],
        each [i]<10,
        each [i=[i]+1, res=lf{[i]}()],
        each [res]

    ),
f=()=>"get token"

    in
    result

 

the idea  (probably naive) is to make believe (I don't know who or what) that they are functions call different, while instead they are the same call

 

lbendlin
Super User
Super User

Here's a simplified version. See if that can get around the cache issue. @ImkeF Any suggestion on how to avoid caching?

 

 

let
    Source = List.Generate(()=>0,each _<10,each _+1),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Invoked Custom Function" = Table.AddColumn(#"Converted to Table", "SessionId", each fnAuthorization())
in
    #"Invoked Custom Function"

 

 

 

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