<?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 How to apply updateFilters method using Power Bi Embedded ? in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/How-to-apply-updateFilters-method-using-Power-Bi-Embedded/m-p/2760394#M38574</link>
    <description>&lt;P&gt;Hello, so I am trying to add a filter after the report loads but it gives me this error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'Add')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the code I am using from the offical documentation from&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/control-report-filters#update-filters" target="_self"&gt;Here&lt;/A&gt;&amp;nbsp;, why is it not recognising the Add property?&lt;BR /&gt;&lt;BR /&gt;Here is my embed code for clarification, any help is much appreciated:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    &amp;lt;script type="text/javascript"&amp;gt;
        $(document).ready(async function () {
            var accessToken = "@Model.EmbedToken.Token";
            // Read embed URL from Model
            var embedUrl = "@Html.Raw(Model.EmbedUrl)";

            // Read report Id from Model
            var embedReportId = "@Model.Id";


            var embedUserName = "@Model.Username";


            // Get models. models contains enums that can be used.
            var models = window['powerbi-client'].models;

            // Embed configuration used to describe the what and how to embed.
            // This object is used when calling powerbi.embed.
            // This also includes settings and options such as filters.
            // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.

            const userIdFilter = {
                $schema: "http://powerbi.com/product/schema#basic",
                target: {
                    table: "reports users",
                    column: "UserName"
                },
                operator: "In",
                values: [embedUserName],
                filterType: models.FilterType.BasicFilter,
                requireSingleSelection: true
            };

            var config = {
                type: 'report',
                tokenType: models.TokenType.Embed,
                accessToken: accessToken,
                embedUrl: embedUrl,
                id: embedReportId,
                permissions: models.Permissions.All,
                settings: {
                    filterPaneEnabled: false,
                    navContentPaneEnabled: true,
                }
            };

            // Get a reference to the embedded report HTML element
            var reportContainer = $('#embedContainer')[0];

            if ("@Model.Username" != "") {
                $("#RLS").prop('checked', true);
                $("#RLSdiv").show();
            }
            else {
                $("#RLS").prop('checked', false);
                $("#RLSdiv").hide();
            }

            if ("@Model.IsEffectiveIdentityRequired.GetValueOrDefault()" == "True") {
                $("#noRLSdiv").hide();
                $("#RLS").removeAttr("disabled");
                $("#RLS").change(function () {
                    if ($(this).is(":checked")) {
                        $("#RLSdiv").show(300);
                    } else {
                        $("#RLSdiv").hide(200);
                    }
                });
            }
            else {
                $("#noRLSdiv").show();
            }
            // Embed the report and display it within the div container.
            var report = powerbi.embed(reportContainer, config);
            report.on('loaded', event =&amp;gt; {
                //if (embedUserName == "tester")
                runUpdate();
                    });
            async function runUpdate() {
                console.log("run update?");
                await report.updateFilters(models.FiltersOperations.Add, userIdFilter);
            }
        });
    &amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Sep 2022 14:24:12 GMT</pubDate>
    <dc:creator>SoulsSama</dc:creator>
    <dc:date>2022-09-11T14:24:12Z</dc:date>
    <item>
      <title>How to apply updateFilters method using Power Bi Embedded ?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-apply-updateFilters-method-using-Power-Bi-Embedded/m-p/2760394#M38574</link>
      <description>&lt;P&gt;Hello, so I am trying to add a filter after the report loads but it gives me this error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'Add')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the code I am using from the offical documentation from&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/control-report-filters#update-filters" target="_self"&gt;Here&lt;/A&gt;&amp;nbsp;, why is it not recognising the Add property?&lt;BR /&gt;&lt;BR /&gt;Here is my embed code for clarification, any help is much appreciated:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    &amp;lt;script type="text/javascript"&amp;gt;
        $(document).ready(async function () {
            var accessToken = "@Model.EmbedToken.Token";
            // Read embed URL from Model
            var embedUrl = "@Html.Raw(Model.EmbedUrl)";

            // Read report Id from Model
            var embedReportId = "@Model.Id";


            var embedUserName = "@Model.Username";


            // Get models. models contains enums that can be used.
            var models = window['powerbi-client'].models;

            // Embed configuration used to describe the what and how to embed.
            // This object is used when calling powerbi.embed.
            // This also includes settings and options such as filters.
            // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.

            const userIdFilter = {
                $schema: "http://powerbi.com/product/schema#basic",
                target: {
                    table: "reports users",
                    column: "UserName"
                },
                operator: "In",
                values: [embedUserName],
                filterType: models.FilterType.BasicFilter,
                requireSingleSelection: true
            };

            var config = {
                type: 'report',
                tokenType: models.TokenType.Embed,
                accessToken: accessToken,
                embedUrl: embedUrl,
                id: embedReportId,
                permissions: models.Permissions.All,
                settings: {
                    filterPaneEnabled: false,
                    navContentPaneEnabled: true,
                }
            };

            // Get a reference to the embedded report HTML element
            var reportContainer = $('#embedContainer')[0];

            if ("@Model.Username" != "") {
                $("#RLS").prop('checked', true);
                $("#RLSdiv").show();
            }
            else {
                $("#RLS").prop('checked', false);
                $("#RLSdiv").hide();
            }

            if ("@Model.IsEffectiveIdentityRequired.GetValueOrDefault()" == "True") {
                $("#noRLSdiv").hide();
                $("#RLS").removeAttr("disabled");
                $("#RLS").change(function () {
                    if ($(this).is(":checked")) {
                        $("#RLSdiv").show(300);
                    } else {
                        $("#RLSdiv").hide(200);
                    }
                });
            }
            else {
                $("#noRLSdiv").show();
            }
            // Embed the report and display it within the div container.
            var report = powerbi.embed(reportContainer, config);
            report.on('loaded', event =&amp;gt; {
                //if (embedUserName == "tester")
                runUpdate();
                    });
            async function runUpdate() {
                console.log("run update?");
                await report.updateFilters(models.FiltersOperations.Add, userIdFilter);
            }
        });
    &amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Sep 2022 14:24:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-apply-updateFilters-method-using-Power-Bi-Embedded/m-p/2760394#M38574</guid>
      <dc:creator>SoulsSama</dc:creator>
      <dc:date>2022-09-11T14:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply updateFilters method using Power Bi Embedded ?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-apply-updateFilters-method-using-Power-Bi-Embedded/m-p/2760835#M38581</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/433614"&gt;@SoulsSama&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;I think this should be related to the parameter that you used in updatefilters function. If you are not familiar with filter structures, you can try to use getfilter function to get the sample data with default filter structures.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 04:06:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-apply-updateFilters-method-using-Power-Bi-Embedded/m-p/2760835#M38581</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-12T04:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply updateFilters method using Power Bi Embedded ?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-apply-updateFilters-method-using-Power-Bi-Embedded/m-p/2761093#M38586</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;First of all thank you for your suggestion, I tried getFilters function and logged the response, it is working but I don't see how will this solve my problem in here? I have a custom filter and it works normally when I apply it directly inside my config object, the problem is that I want to add the filter when the report is ( on loaded ), in the documentation Add function is written and I just copied the syntax as it is, but the error says that it's undefined, which means that Add property does not exist for FilterOperations method, I hope this clarify my problem, any more tips and recommendation would be much appreciated.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Here is a screenshot for the code line that I'm trying to implement:&lt;/STRONG&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chrome_nZiJddXgaw.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/781771iB07982A86874E999/image-size/large?v=v2&amp;amp;px=999" role="button" title="chrome_nZiJddXgaw.png" alt="chrome_nZiJddXgaw.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 07:27:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-apply-updateFilters-method-using-Power-Bi-Embedded/m-p/2761093#M38586</guid>
      <dc:creator>SoulsSama</dc:creator>
      <dc:date>2022-09-12T07:27:41Z</dc:date>
    </item>
  </channel>
</rss>

