Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi guys,
As mentionned in the title, I would like to understand what this function below does
let
Yesterday = "/received_payments_report_"&
Date.ToText( DateTime.Date( Date.AddDays(DateTime.LocalNow(), -1)) , "yyyy_MM_dd")&".csv",
getUserData = (loops as number, optional data_list as list ) =>
let
Query = Web.Contents(
"https://URL of the data source/", [RelativePath= Record.Field(_MerchantAccountHelper{loops}, "Merchant Account Name") & Yesterday]
),
Results = {Csv.Document(Query, [Delimiter = ",", Columns = 88, QuoteStyle = QuoteStyle.None])},
currentLoop = loops + 1,
currentResults =
if data_list is null then Results
else List.Combine({data_list, Results}) ,
output =
if loops > Table.RowCount(_MerchantAccountHelper) then currentResults
else @getUserData(currentLoop, currentResults )
in
output
in
getUserData
How the value of currentLoop and currentResults have been initiated ? I'm curious about it because I don't see something like currentLoop = 0 and loops doesn't also have a value. Same thing for currentResults.
Why is there an IF loop > Table.RowCount.... ?
Thank you in advance !
Hi @bboy0009
This query returns a function (value) that is designed to fetch CSV reports from a web source. getUserData has two parameters to fetch data, loops as number, and optionally appends it's restult to a list of data, optional data_list as list, That answers your fist question, the value of loop in currentLoop is determined by the user's first argument value when this function is invoked.
The if loops > Table.RowCount determines whether to continue looping or to return the final results. If the loop counter exceeds the number of merchant accounts, it returns the currentResults, ending the looping process. Otherwise, it recursively calls getUserData incrementing the loop counter +1, continuing the looping process to fetch and combine a new set of results to the previous ones.
I hope this is helpful
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.