Quantcast
Channel: All Developer posts
Viewing all articles
Browse latest Browse all 48064

Re: Construct Filter with Javascript function

$
0
0



Below code works in my test. You can debug your filter by using the alert statement before applying it. Check more details on Filters. By the way, do note that when using "In", it is values and when other operators it is a scalar value. You may have to put more logics in your function.

var arr = [1,2,3,4,6,8]

function advancedFilter(table, column, logicalOperator, operator, value){
    
    if (logicalOperator === undefined) {
        logicalOperator = "And";
    }
    if (operator === undefined) {
        operator = "Is";
    }
    if (value === undefined) {
        value = 0;
    }

    return filter = {
        $schema: "http://powerbi.com/product/schema#advanced",
        target: {
            table: table,
            column: column
        },
        //logicalOperator: logicalOperator,
        //conditions: [
        //    {
                operator: operator,
//It is "values" when using a operator "In"values: value // } //] }; } alert(JSON.stringify(advancedFilter("table","column","","In",arr)));

 

 


Viewing all articles
Browse latest Browse all 48064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>