Forum Discussion

danieleperilli's avatar
danieleperilli
Kudo Commander
8 years ago
Solved

Advanced Filter

I'm trying to use the AdvancedFilter feature in my visual, but something is not clear to me.

I'm using the following code:

let inValues = [];
let containsValue = '';

let conditions = [];
for (let i = 0; i < inValues.length; i++)
    conditions.push({
        operator: 'Is',
        value: inValues[i]
    });
conditions.push({
    operator: 'Contains', 
    value: containsValue
});
let advancedFilter = new window['powerbi-models'].AdvancedFilter({
    table: TABLE_NAME,
    column: COLUMN_NAME
}, (conditions.length > 1 ? 'Or' : 'And'), conditions);
host.applyJsonFilter(advancedFilter, 'general', 'filter', FilterAction.merge);

After the last line, the filter is applied correctly to the report, but my visual does not receive a filtered data in the subsequently update. 

Is it normal?

  • Hi danieleperilli,

     

    This is expected behavior as a filter is applied to other visuals on the same report page.

    A custom visual that applies a filter will not get the filtered data.

     

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]

5 Replies

Replies have been turned off for this discussion
  • v-viig's avatar
    v-viig
    Community Champion

    Hi danieleperilli,

     

    This is expected behavior as a filter is applied to other visuals on the same report page.

    A custom visual that applies a filter will not get the filtered data.

     

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]

    • danieleperilli's avatar
      danieleperilli
      Kudo Commander

      Thanks v-viig.

      It would useful to have the filtered data as separated node in the dataviews returned in the update. Is it something you could evaluate to insert in the future? 

      • v-viig's avatar
        v-viig
        Community Champion

        Could you please describe why your custom slicer should receive a filtered data?

         

        Ignat Vilesov,

        Software Engineer

         

        Microsoft Power BI Custom Visuals

        [email protected]