0

I am using PowerBIEmbed component to display powerBI report, Power BI report is using telemetry query to filter data. telemetry has columns like

name CustomColumnJson { Id, Event }

I want to apply filter over Id column, then I am applying filter like , but filter is not working.

       <PowerBIEmbed
            embedConfig={{
                type: 'report', 
                id: '*********************',  //client_id
                embedUrl: "", //embed url, if u dont knw refer powerbi api docs
                accessToken: this.state.accessToken,
                tokenType: models.TokenType.Aad,
filters: [{
                $schema: "http://powerbi.com/product/schema#basic",
                target: {
                table: "Event",
                column: "CustomColumnJson.Id"
                },
                operator: "In",
                values: "XYZ"
            }],
                settings: {
                    panes: {
                        filters: {
                            expanded: false,
                            visible: true
                        }
                    },
                }
            }} eventHandlers={
                new Map([
                    ['loaded', function () { console.log('Report loaded'); }],
                    ['rendered', function () { console.log('Report rendered'); }],
                    ['error', function (event) { console.log(event.detail); }]
                ])
            }
            cssClassName={"container"}
            getEmbeddedComponent={(embeddedReport) => {
                window.report = embeddedReport;
            }}
        />

1 Answer 1

0

Values in the filters should be of Array of (strings or boolean or numbers). Try this code and LMK if this works.

filters: [{
                $schema: "http://powerbi.com/product/schema#basic",
                target: {
                table: "Event",
                column: "CustomColumnJson.Id"
                },
                operator: "In",
                values: ["XYZ"]
            }],

Sample :

const filter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
    table: "Geo",
    column: "Region"
},
operator: "In",
values: ["West", "Central"]}; 
// Add the filter to the report's filters.
try {
await report.updateFilters(models.FiltersOperations.Add, [filter]);
console.log("Report filter was added.");}
catch (errors) {
console.log(errors);}

Here is my table and column name.

enter image description here

Filter section before applying filter enter image description here

Filter section after applying filter enter image description here

References: https://learn.microsoft.com/javascript/api/overview/powerbi/control-report-filters

Sign up to request clarification or add additional context in comments.

7 Comments

Yes, I passed array by mistake I have written value, but still not filtering, but at rightside when I looked into filter then filter column is showing with "All" value not the passed filtered parameter value.
Can you recheck your column name whether its correct or not ? I didn't get your column name correctly
column name is correct, do I need add applicable column name in Power BI report? I mean, PowerBI report should define the applicable filter column name in power BI filter section?
If I understood Your question correctly, No need to add column to filter section in powerbi. It will automatically get added to filter section when applying filter. edited my answer with snapshots. If possible can you give a screenshot of your table with columns?
I have checked your code, you are calling update filter method, where and when to call updateFilter method? Please review my posted code also. I am passing column name correct as you mention.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.