<?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 Re: Guaranteeing filter implementation prior to render in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Guaranteeing-filter-implementation-prior-to-render/m-p/3695705#M49512</link>
    <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/316579"&gt;@nckpedersen&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the error message displayed, you can check the data used, possibly due to data inconsistencies or data type mismatches, to ensure that it is formatted correctly, that the data to be filtered does not contain non-numeric values and contains only numeric values&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-data-types" target="_blank"&gt;Data types in Power BI Desktop - Power BI | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Feb 2024 07:53:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-02-13T07:53:05Z</dc:date>
    <item>
      <title>Guaranteeing filter implementation prior to render</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Guaranteeing-filter-implementation-prior-to-render/m-p/3694721#M49510</link>
      <description>&lt;P&gt;I'm currently attempting to catch an unexpected error occurring within an asynchronous promise, specifically when updating the filter of a Power BI embedded report. However, I'm encountering difficulty in capturing this error within the catch block.&lt;/P&gt;&lt;P&gt;Here's a snippet of my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;return new Promise((resolve, reject) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; let rep_res = report.updateFilters(models.FiltersOperations.Add, [filter, filter2])&lt;BR /&gt;&amp;nbsp; &amp;nbsp; .then(() =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; resolve('Filter Applied');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; })&lt;BR /&gt;&amp;nbsp; &amp;nbsp; .catch((error) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; reject("Failed to apply filters: " + error);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; });&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;The error occurs after logging "Filter Applied" in the console and is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Error : Error: \&amp;lt;rect\&amp;gt; attribute x: Expected length, "NaN".&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've confirmed that this error originates from the updateFilters function because removing the code associated with it eliminates the error.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The filter objects appear to be correct, as the error only occurs with a specific report.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've consulted the Power BI documentation regarding the addition of filters to reports, but I couldn't find any guidance on error handling.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;powerbi documentation to add reports: &lt;A href="https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/control-report-filters#add-new-filters-to-the-report-filters" target="_blank" rel="noopener"&gt;https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/control-report-filters#add-new-filters-to-the-report-filters&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In an attempt to resolve this issue, I've tried several approaches, including:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Storing the response of the then method and the promise itself in variables to find any trace of error&lt;/LI&gt;&lt;LI&gt;Implementing try-catch blocks&lt;/LI&gt;&lt;LI&gt;Using setTimeout to address asynchronous behavior&lt;/LI&gt;&lt;LI&gt;Utilizing window.onerror&lt;/LI&gt;&lt;LI&gt;Adding a setTimeout function before resolving the promise&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Any assistance or insights into resolving this issue would be greatly appreciated.&amp;nbsp;Thank&amp;nbsp;you.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 19:39:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Guaranteeing-filter-implementation-prior-to-render/m-p/3694721#M49510</guid>
      <dc:creator>nckpedersen</dc:creator>
      <dc:date>2024-02-12T19:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Guaranteeing filter implementation prior to render</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Guaranteeing-filter-implementation-prior-to-render/m-p/3695705#M49512</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/316579"&gt;@nckpedersen&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the error message displayed, you can check the data used, possibly due to data inconsistencies or data type mismatches, to ensure that it is formatted correctly, that the data to be filtered does not contain non-numeric values and contains only numeric values&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-data-types" target="_blank"&gt;Data types in Power BI Desktop - Power BI | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 07:53:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Guaranteeing-filter-implementation-prior-to-render/m-p/3695705#M49512</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-13T07:53:05Z</dc:date>
    </item>
  </channel>
</rss>

