Forum Discussion

JohnTheDoe's avatar
JohnTheDoe
Frequent Visitor
8 years ago

Custom filters in custom visuals

I currently have a table where the data in one of the columns are of type string, like "100% 22 hours". 

 

Let's say I want to create a custom visual that counts the amount of rows where the data in that column is greater than 100%. However, because the data is a string, to filter those rows I can't exactly use "GreaterThan" with the AdvancedFiltering API, like this:

 

let conditions: IAdvancedFilterCondition[] = [];

conditions.push({ operator: "GreaterThan", value: "100%" });

Let's also that I am not allowed to clean the dataset before inputting it into PowerBI. Is there a way for me to create a custom function that is responsible for the logic deciding which data gets filtered and pass it into the AdvancedFilter API, like below?

 

let conditions: IAdvancedFilterCondition[] = [];

conditions.push((data) : boolean => {
//Do some parsing logic to extract the percent number

//Do some logic to determine if extracted number is greater than 100

//return true or false
});

 

If not, how else could I achieve this filtering logic in this scenario?

 

Thanks.

1 Reply

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

    It seems you can try to use Contains condition operator instead of LessThan to filter text values.

     

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]