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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.