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!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I'm working with a 3rd party REST API that returns an empty Results array when all of the data has been consumed. "Results":[]
This seems like it should be easy enough but it has me stumped. I'm returning the Results to a loop that tests for Results being null which doesn't work, but I'm not sure how to test for an empty array?
GetActivities = (Index, access_token) =>
let
Skip = Text.From(Index * RecordsPerPage),
RawData = Web.Contents(BaseUrl,
[
Headers=[
Authorization="Bearer " & access_token
],
RelativePath="/crm/activity?$skip=" & Skip
]
),
Source = Json.Document(RawData),
Result1 = Source[Result]
//res = try Source[Result] otherwise null,
//Result3 = try res otherwise null
in Result1,
access_token = GetToken(),
TestRun = List.Generate (
()=>
[Results = try GetActivities(0, access_token) otherwise null, Page = 0],
each [Results] <> null and [Page]<5,
each [Results = try GetActivities([Page] +1, access_token) otherwise null, Page = [Page]+1],
each [Results]
)
in
TestRun
Any pointers for a newbie would be appreciated. Thanks in advance.
Solved! Go to Solution.
That did it JirkaZ, prolem solved.
Results2 = if (Record.HasFields(Results1{0}, {"Id"})) then Results1 else null
How can I integrate it into the code? I'm too new
@stew_ia Not sure from the top of my head but Json.Document typically returns a record, correct? So you could test the record with Record.HasFields perhaps?
That did it JirkaZ, prolem solved.
Results2 = if (Record.HasFields(Results1{0}, {"Id"})) then Results1 else null
Hi @stew_ia ,
Glad to hear that. Please accept your reply as a solution so that people who may have the same question can get the solution directly.
Best Regards,
Icey
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 53 | |
| 47 | |
| 30 | |
| 15 | |
| 14 |
| User | Count |
|---|---|
| 88 | |
| 73 | |
| 39 | |
| 26 | |
| 25 |