# Power BI M code help

**URL:** <https://community.hubspot.com/t/power-bi-m-code-help/135678>\
**Category:** APIs & Integrations\
**Tags:** starter\
**Created:** [July 4, 2025, 11:00am UTC](https://community.hubspot.com/t/power-bi-m-code-help/135678 "2025-07-04T11:00:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SBhatti](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@SBhatti](https://community.hubspot.com/u/SBhatti)\
**Post date:** [July 4, 2025, 11:00am UTC](https://community.hubspot.com/t/power-bi-m-code-help/135678/1 "2025-07-04T11:00:04Z")

</div>

Hi  
Can anyone have a look at this, I have connected Power Bi to HS, however all tge contacts atre not uploadeing, have I reached a request Limit?  
let  
&nbsp;&nbsp;&nbsp;&nbsp;accessToken = “My Token”,  
&nbsp;&nbsp;&nbsp;&nbsp;GetPages = (queryParams as record) =\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Host = “[api.hubapi.com](http://api.hubapi.com)”,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Source = Json.Document(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Web.Contents(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“https://” & Host,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Results = Source[results],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NextAfter = if Record.HasFields(Source, “paging”) and Record.HasFields(Source[paging], “next”) and Record.HasFields(Source[paging][next], “after”) then  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Source[paging][next][after]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CleanQuery = Record.RemoveFields(queryParams, {“after”}, MissingField.Ignore),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NextQuery = if NextAfter \<\> null then  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Record.AddField(CleanQuery, “after”, NextAfter)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoreResults = if NextQuery \<\> null then  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@GetPages(NextQuery)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{},  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Combined = List.Combine({Results, MoreResults})  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Combined,  
&nbsp;&nbsp;&nbsp;&nbsp;Fullset = GetPages([  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;limit = “100”,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;properties = {“hubspot\_owner\_id”, “firstname”, “lastname”, “company”, “email”, “twc\_champion”, “location\_\_\_region”,“location\_\_\_region\_dropdown”}  
&nbsp;&nbsp;&nbsp;&nbsp;]),  
&nbsp;&nbsp;&nbsp;&nbsp;ContactsTable = Table.FromRecords(Fullset),

---

<div class="post-metadata">

**Author:** ![Victor\_Becerra](https://avatars.discourse-cdn.com/v4/letter/v/87869e/32.png) [@Victor\_Becerra](https://community.hubspot.com/u/Victor_Becerra)\
**Post date:** [July 4, 2025, 4:51pm UTC](https://community.hubspot.com/t/power-bi-m-code-help/135678/2 "2025-07-04T16:51:51Z")

</div>

**Hi @SBhatti ,**

Thank you for reaching out to the Community!

I’d like to invite some community members who are subject matter experts to join this conversation.

@johnelmer @GRajput [@webdew](https://community.hubspot.com/t5/user/viewprofilepage/user-id/131510) - Would you be able to share any insights on this? Your expertise would be greatly appreciated.

Best regards,

---

<div class="post-metadata">

**Author:** ![Victor\_Becerra](https://avatars.discourse-cdn.com/v4/letter/v/87869e/32.png) [@Victor\_Becerra](https://community.hubspot.com/u/Victor_Becerra)\
**Post date:** [July 16, 2025, 4:33pm UTC](https://community.hubspot.com/t/power-bi-m-code-help/135678/3 "2025-07-16T16:33:53Z")

</div>

Hi @SBhatti ! To help resolve this issue, could you please share the specific error message you’re seeing or describe what’s happening on your screen? Screenshots would also be very helpful if you’re able to provide them.

This information will help us provide you with the most accurate solution. Thank you!

---

<div class="post-metadata">

**Author:** ![SBhatti](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@SBhatti](https://community.hubspot.com/u/SBhatti)\
**Post date:** [July 21, 2025, 10:44am UTC](https://community.hubspot.com/t/power-bi-m-code-help/135678/4 "2025-07-21T10:44:37Z")

</div>

Hi

There is no error message, the issue is that not all the cotacts are migrated from HS to Power Bi

---

<div class="post-metadata">

**Author:** ![Victor\_Becerra](https://avatars.discourse-cdn.com/v4/letter/v/87869e/32.png) [@Victor\_Becerra](https://community.hubspot.com/u/Victor_Becerra)\
**Post date:** [August 4, 2025, 8:06pm UTC](https://community.hubspot.com/t/power-bi-m-code-help/135678/5 "2025-08-04T20:06:29Z")

</div>

Hi @SBhatti ,

Looking at your M code, the issue is likely related to rate limiting or pagination handling when retrieving all your contacts. Here are a couple of solutions that should resolve this:

**Option 1: HubSpot’s Official Power BI Connector** This is available in the HubSpot App Marketplace and handles rate limiting, pagination, and automated data refresh automatically. You can find more details about this solution here: [https://community.hubspot.com/t5/APIs-Integrations/Hubspot-to-Power-BI-integration/m-p/1026480#M75823](https://community.hubspot.com/t5/APIs-Integrations/Hubspot-to-Power-BI-integration/m-p/1026480#M75823)

**Option 2: Third-Party Integration Tools** There are several robust connectors specifically designed for HubSpot-Power BI integration, with built-in templates and proper API management. You can see the discussion and recommendations here: [https://community.hubspot.com/t5/APIs-Integrations/Integrating-Hubspot-to-Power-Bi/m-p/1070955/highlight/true#M78317](https://community.hubspot.com/t5/APIs-Integrations/Integrating-Hubspot-to-Power-Bi/m-p/1070955/highlight/true#M78317)

These connector solutions are purpose-built to handle API limitations and will save you troubleshooting time while ensuring all your contacts are retrieved properly.

Let us know which direction you’d like to go or if you need more specific guidance on either of these options!

Best,

Victor
