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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

report.getFilters has stopped returning filters

We have been using the report.getFilters method for many months, and I accidentally discovered today that it's no longer working.  The error being returned in the response is "Could not get filters."  There haven't been any changes to the application, but now the basic functionality we're using filters for is broken.

 

I tried upgrading powerbi.js to 2.8.0, and that hasn't resolved it.

Status: New
Comments
davisbizhq
Frequent Visitor

This has not itself after a couple of minutes of spinning wait gifs.  It appears Power BI has been refreshed.  But report.getFilters is still not working.

v-yuta-msft
Community Support

@davisbizhq ,

 

Seems like there's something wrong with this JS function, but I haven't seen any update log here. So I would suggest you to create a support ticket to achieve further help.

 

Regards,

Jimmy Tao

davisbizhq
Frequent Visitor

Hi, Jimmy, et. al., (I couldn't find a specific mentionee), thanks for the reply.

 

I was able to resolve this by moving my code from the loaded event to the pageChanged event.  It seems that there were some performance changes made in Power BI.  Previously, using a multi-stage load/render, we were setting filters in the "loaded" event:

 

        report.on("loaded", function() {
            // Get the bookmarks to find a match to the display name pass in from controller.
            report.bookmarksManager.getBookmarks()
                .then(function (bookmarks) {
                    bookmarks.forEach(function (bookmark) {
                        if (bookmark.displayName == '@Model.GlobalLanguageID' || bookmark.displayName == '@Model.InitialLanguageBookmarkName')
                            report.bookmarksManager.apply(bookmark.name);
                    });
                });

            // Establish report language by setting filters on tabular model dimensions.  Conditions -- language has been included in the URL, and
            // the underlying data source is the "GlobalPestModel".  Alternatively we may get all filters and iterate through each one, setting the
            // value to the current language if the target includes LanguageID.
            report.getFilters()
                .then(function (filters) {
                    filters.forEach(function (filter)
                    {
                        if (filter.target.column == "Language ID") { filter.values = [globalLanguage]; }
                    });
                    report.setFilters(filters);
                });
            report.render();
        });

In order to resolve this, the new code is byte-for-byte the same, but in the "pageChanged" event:

 

        /* When the report loads to the initial page, or the user navigates to another page, initiate a controller method that
         * logs the page navigation for analysis. */
        report.off('pageChanged');
        report.on('pageChanged', function (event) {
            const page = event.detail.newPage;
            $.ajax({
                cache: false,
                async: true,
                type: "POST",
                url: "@Url.Action("LogPageChanges", "Home")",
                data:
                {
                    pageName: page.displayName,
                    reportName: "@Model.Name"
                },
                success: function(data) {
                    console.log('%s was set as active page',page.displayName);
                }
            });

            // Establish report language by setting filters on tabular model dimensions.  Conditions -- language has been included in the URL, and
            // the underlying data source is the "GlobalPestModel".  Alternatively we may get all filters and iterate through each one, setting the
            // value to the current language if the target includes LanguageID.
            report.getFilters()
                .then(function (filters) {
                    filters.forEach(function (filter) {
                        if (filter.target.column == "Language ID") { filter.values = [globalLanguage]; }
                    });
                    report.setFilters(filters);
                });

        });

I wonder whether it's due to July performance improvements rendering date and dropdown slicers?  The queries affected by the language filtering also include dates.  

 

I had opened a support ticket and hope to arrive at a conclution about that before it closes.