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

Value.WaitFor Pattern

Hello there!

 

I try to realize helper function Value.WaitFor:

let
  Value.WaitFor = (producer as function, interval as function, optional count as number) as any =>
    let
        list = List.Generate(
            () => {0, null},
            (state) => state{0} <> null and (count = null or state{0} < count),
            (state) => if state{1} <> null then {null, state{1}} else {1 + state{0}, Function.InvokeAfter(() => producer(state{0}), interval(state{0}))},
            (state) => state{1})
    in
        List.Last(list)
in
  Value.WaitFor

 

But when i add this function to my request - PQ appeals to web service only one time and return null although by condition he must appeals 5 times. Can somebody explain me where i make mistake? I am hope for your help.

 

My request:

let
  result = fnValueWaitFor(
      (iteration) => 
        let
          data = Json.FromValue([StatisticsSessionId = StatisticsId]),
          headers = [
            #"accept"             = "*/*", 
            #"ScoutAuthorization" = AuthorizationId, 
            #"Content-Type"       = "application/json"
          ],
          web = Web.Contents(
              "url", 
              [
                Content              = data, 
                Headers              = headers, 
                Timeout              = #duration(0, 0, 0, 10), 
                ManualStatusHandling = {404, 400}
              ]
            ),
          buffered = Binary.Buffer(web),
          status = Json.Document(buffered)[ChunkInfo][Status][Value],
          actual_result = if status = "Ok" then Json.Document(buffered) else null
        in
          actual_result, 
      (iteration) => #duration(0, 0, 0, 1), 
      5
    )
in
  result

 

5 REPLIES 5
Anonymous
Not applicable

I am also getting the error message when I try to use this pattern.

 

Expression.Error: The name 'Value.WaitFor' wasn't recognized. Make sure it's spelled correctly.

 

@Bessonnizza were you able to get this pattern working?

 

 

jenngusi_spg
Frequent Visitor

Hello. I am trying to incorporate Value.WaitFor in my code but it is unrecognizable? Was this disabled by Power BI? If yes, are there any alternative?

Need help!

 

Thanks experts!

 

This was never a part of the released version of Power BI. It is a custom function and needs to be entered as such.

Somebody have any ideas?

This was never a part of the released version of Power BI. It is a custom function and needs to be entered as such.

Helpful resources

Announcements
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.