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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jigar1276
Helper I
Helper I

Need to get total of records returned by API in a variable

I am making API call in Power BI:

Source = Json.Document(Web.Contents( APIURL & "/commonapi/search?name=myName&eCode=FCD&recordStart=1&recordLimit=1")),
    Total = Source[results-total]

The response JSON is:

 

Jigar1276_0-1626267135707.png

I want to get the results-total which is 152 in variable "Total". But I am getting error in line:

Total = Source[results-total]

 

As "results-total" is inside the "responseHeader" in JSON. What can be the correct code line for Total = Source[results-total]?

 

Thanks in advance for any help

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

It may be Source[responseHeader][response-total], unless either of those are arrays, but why not just use the Power BI interface to drill into the JSON, which will create the needed Navigation step?

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
Jigar1276
Helper I
Helper I

@mahoneypat 

Thanks for the quick solution.

 

I have to make multiple calls to API with recordStart and recordLimit parameters. API is returning 1000 records only, so pagination is required and hence for looping purpose I need to know total records returned so I can loop the API calls accordingly.

Please see if this video helps you out with pagination including the total count.

Power BI - Tales From The Front - REST APIs - YouTube

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Employee
Employee

It may be Source[responseHeader][response-total], unless either of those are arrays, but why not just use the Power BI interface to drill into the JSON, which will create the needed Navigation step?

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors