<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic this.host.fetchMoreData() not working on initial load in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/this-host-fetchMoreData-not-working-on-initial-load/m-p/2349365#M4296</link>
    <description>&lt;P&gt;I just wanted to share this in case anyone else runs into a similar issue. I am running powerbi-visuals-api v4.2.0. While implementing &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/visuals/fetch-more-data" target="_self"&gt;fetchMoreData()&lt;/A&gt;&amp;nbsp;to pull in more than the default allowed 30,000 rows, I was running into an issue where upon initial load, nothing would appear. If I triggered an update (e.g. data filter), everything worked as expected. I could trigger multiple subsequent updates and the data and visual returned correctly, only the initial load was having an issue. After trying a bunch of different things, below is how I ended up solving it. The key ended up being to call refreshHostData() followed by update() on the initial load.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Custom-Visuals-Development/Pbiviz-to-fetch-more-than-30-000-row/m-p/957056" target="_self"&gt;This thread&lt;/A&gt; was very helpful, especially the responses from&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="3821" data-lia-user-login="jppp" class="lia-mention lia-mention-user"&gt;jppp&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="397" data-lia-user-login="dm-p" class="lia-mention lia-mention-user"&gt;dm-p&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;            this._visualUpdateOptions = options;
            const dataView = options.dataViews[0];
            const lastCall = (dataView.metadata.segment) ? false : true;

            if (this._initialLoad) {
                this._initialLoad = false;
                if (!lastCall) {
                    this._visualUpdateOptions.dataViews[0].metadata.segment = true;
                    this._host.refreshHostData();
                    this.update(this._visualUpdateOptions);
                }
            }

            if (!lastCall) {
                let moreData: boolean = this._host.fetchMoreData();
                if ((moreData)) {
                    this._initialLoad = false;
                    this._segmentCounter += 1;
                    return;
                } 
            }

            console.log(`segments: ${this._segmentCounter}  rows: ${options.dataViews[0].table.rows.length}`)
            this._segmentCounter = 1;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Feb 2022 16:48:58 GMT</pubDate>
    <dc:creator>giammariam</dc:creator>
    <dc:date>2022-02-20T16:48:58Z</dc:date>
    <item>
      <title>this.host.fetchMoreData() not working on initial load</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/this-host-fetchMoreData-not-working-on-initial-load/m-p/2349365#M4296</link>
      <description>&lt;P&gt;I just wanted to share this in case anyone else runs into a similar issue. I am running powerbi-visuals-api v4.2.0. While implementing &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/visuals/fetch-more-data" target="_self"&gt;fetchMoreData()&lt;/A&gt;&amp;nbsp;to pull in more than the default allowed 30,000 rows, I was running into an issue where upon initial load, nothing would appear. If I triggered an update (e.g. data filter), everything worked as expected. I could trigger multiple subsequent updates and the data and visual returned correctly, only the initial load was having an issue. After trying a bunch of different things, below is how I ended up solving it. The key ended up being to call refreshHostData() followed by update() on the initial load.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Custom-Visuals-Development/Pbiviz-to-fetch-more-than-30-000-row/m-p/957056" target="_self"&gt;This thread&lt;/A&gt; was very helpful, especially the responses from&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="3821" data-lia-user-login="jppp" class="lia-mention lia-mention-user"&gt;jppp&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="397" data-lia-user-login="dm-p" class="lia-mention lia-mention-user"&gt;dm-p&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;            this._visualUpdateOptions = options;
            const dataView = options.dataViews[0];
            const lastCall = (dataView.metadata.segment) ? false : true;

            if (this._initialLoad) {
                this._initialLoad = false;
                if (!lastCall) {
                    this._visualUpdateOptions.dataViews[0].metadata.segment = true;
                    this._host.refreshHostData();
                    this.update(this._visualUpdateOptions);
                }
            }

            if (!lastCall) {
                let moreData: boolean = this._host.fetchMoreData();
                if ((moreData)) {
                    this._initialLoad = false;
                    this._segmentCounter += 1;
                    return;
                } 
            }

            console.log(`segments: ${this._segmentCounter}  rows: ${options.dataViews[0].table.rows.length}`)
            this._segmentCounter = 1;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Feb 2022 16:48:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/this-host-fetchMoreData-not-working-on-initial-load/m-p/2349365#M4296</guid>
      <dc:creator>giammariam</dc:creator>
      <dc:date>2022-02-20T16:48:58Z</dc:date>
    </item>
  </channel>
</rss>

